naive-ui/rollup.config.js
Jiwen Bai 8131aa343c chore: migrate to Vite2 (#347)
* chore: migrate to vite2

* styles: remove unsed code

* chore: update package.json

Co-authored-by: Volankey <jiwen.bai@tusimple.ai>
2021-01-12 13:17:26 +08:00

63 lines
1.3 KiB
JavaScript

const cssRenderPlugin = require('./build/rollup-plugin-css-render')
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const { terser } = require('rollup-plugin-terser')
const replace = require('@rollup/plugin-replace')
const { babel } = require('@rollup/plugin-babel')
function externalValidator (patterns) {
return (id) => {
return patterns.some((pattern) => id.startsWith(pattern))
}
}
// do not use babel when build library, use it when only build the site
module.exports = {
input: 'src-mirror/index.js',
output: [
{
format: 'cjs',
dir: 'lib',
exports: 'named',
preserveModules: true
},
{
format: 'esm',
dir: 'es',
preserveModules: true
}
],
plugins: [
replace({
__DEV__: 'process.env.NODE_ENV !== "production"'
}),
nodeResolve({
extensions: ['.js', '.json']
}),
cssRenderPlugin(),
babel({
babelHelpers: 'bundled'
}),
terser({
mangle: false,
output: {
beautify: true,
indent_level: 2
}
})
],
external: externalValidator([
'async-validator',
'date-fns',
'lodash-es',
'vue',
'treemate',
'css-render',
'@css-render/plugin-bem',
'vueuc',
'vooks',
'evtd',
'vdirs',
'seemly'
])
}