naive-ui/rollup.config.js

61 lines
1.3 KiB
JavaScript
Raw Normal View History

const cssRenderPlugin = require('./build/rollup-plugin-css-render')
2020-10-31 18:02:14 +08:00
const { nodeResolve } = require('@rollup/plugin-node-resolve')
const { terser } = require('rollup-plugin-terser')
2020-11-03 14:05:05 +08:00
const replace = require('@rollup/plugin-replace')
const { babel } = require('@rollup/plugin-babel')
function externalValidator (patterns) {
return (id) => patterns.some((pattern) => id.startsWith(pattern))
}
2020-12-04 19:40:17 +08:00
// do not use babel when build library, use it when only build the site
module.exports = {
input: 'src-mirror/index.js',
2020-02-12 13:44:53 +08:00
output: [
{
format: 'cjs',
2020-10-31 18:02:14 +08:00
dir: 'lib',
2020-11-12 19:34:20 +08:00
exports: 'named',
2020-10-31 18:02:14 +08:00
preserveModules: true
2020-02-12 13:44:53 +08:00
},
{
format: 'esm',
2020-10-31 18:02:14 +08:00
dir: 'es',
preserveModules: true
2020-02-12 13:44:53 +08:00
}
],
plugins: [
2020-11-03 14:05:05 +08:00
replace({
__DEV__: 'process.env.NODE_ENV !== "production"'
}),
2020-10-31 18:02:14 +08:00
nodeResolve({
extensions: ['.js', '.json']
2020-02-12 13:44:53 +08:00
}),
cssRenderPlugin(),
babel({
babelHelpers: 'bundled'
}),
terser({
mangle: false,
output: {
beautify: true,
indent_level: 2
}
})
],
external: externalValidator([
2020-02-12 13:44:53 +08:00
'async-validator',
2020-05-16 22:07:58 +08:00
'date-fns',
2020-02-12 13:44:53 +08:00
'lodash-es',
2020-10-31 18:02:14 +08:00
'vue',
'treemate',
2020-10-28 01:38:23 +08:00
'css-render',
2020-10-09 18:56:22 +08:00
'@css-render/plugin-bem',
2020-10-28 01:38:23 +08:00
'vueuc',
2020-11-03 19:04:08 +08:00
'vooks',
'evtd',
'vdirs',
'seemly'
])
}