56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import typescript from '@rollup/plugin-typescript'
|
|
import babel from '@rollup/plugin-babel'
|
|
import postcss from 'rollup-plugin-postcss'
|
|
import tailwind from 'rollup-plugin-tailwindcss'
|
|
import autoprefixer from 'autoprefixer'
|
|
import resolve from '@rollup/plugin-node-resolve'
|
|
import commonjs from '@rollup/plugin-commonjs'
|
|
import { terser } from 'rollup-plugin-terser'
|
|
|
|
const pkgPath = path.resolve('package.json')
|
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
|
|
const external = [
|
|
...Object.keys(pkg.dependencies || {}),
|
|
...Object.keys(pkg.peerDependencies || {}),
|
|
/@babel\/runtime/
|
|
]
|
|
|
|
export default {
|
|
input: 'src/index.ts',
|
|
output: {
|
|
dir: 'dist',
|
|
format: 'esm',
|
|
sourcemap: true,
|
|
preserveModules: true,
|
|
preserveModulesRoot: 'src'
|
|
},
|
|
external,
|
|
plugins: [
|
|
resolve(),
|
|
commonjs(),
|
|
typescript({
|
|
declaration: true,
|
|
noEmitOnError: true
|
|
}),
|
|
babel({
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
babelHelpers: 'runtime',
|
|
include: ['src/**/*'],
|
|
plugins: ['@babel/plugin-transform-runtime']
|
|
}),
|
|
postcss({
|
|
plugins: [autoprefixer()],
|
|
sourceMap: true,
|
|
extract: true,
|
|
minimize: true
|
|
}),
|
|
tailwind({
|
|
input: './styles/globals.css'
|
|
}),
|
|
terser()
|
|
]
|
|
}
|