2020-11-12 13:30:04 +08:00
|
|
|
const cssRenderPlugin = require('./build/rollup-plugin-css-render')
|
2020-10-31 18:02:14 +08:00
|
|
|
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
2019-12-30 13:15:14 +08:00
|
|
|
const { terser } = require('rollup-plugin-terser')
|
2020-11-03 14:05:05 +08:00
|
|
|
const replace = require('@rollup/plugin-replace')
|
2020-12-16 10:57:40 +08:00
|
|
|
const { babel } = require('@rollup/plugin-babel')
|
2019-12-30 13:15:14 +08:00
|
|
|
|
2020-11-05 15:31:40 +08:00
|
|
|
function externalValidator (patterns) {
|
2020-12-16 10:57:40 +08:00
|
|
|
return (id) => patterns.some((pattern) => id.startsWith(pattern))
|
2020-11-05 15:31:40 +08:00
|
|
|
}
|
|
|
|
|
2020-12-04 19:40:17 +08:00
|
|
|
// do not use babel when build library, use it when only build the site
|
2019-12-30 13:15:14 +08:00
|
|
|
module.exports = {
|
2020-12-06 22:04:36 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
],
|
2019-12-30 13:15:14 +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({
|
2020-12-06 22:04:36 +08:00
|
|
|
extensions: ['.js', '.json']
|
2020-02-12 13:44:53 +08:00
|
|
|
}),
|
2020-11-12 13:30:04 +08:00
|
|
|
cssRenderPlugin(),
|
2020-12-16 10:57:40 +08:00
|
|
|
babel({
|
|
|
|
babelHelpers: 'bundled'
|
|
|
|
}),
|
2019-12-30 13:15:14 +08:00
|
|
|
terser({
|
|
|
|
mangle: false,
|
|
|
|
output: {
|
|
|
|
beautify: true,
|
|
|
|
indent_level: 2
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
2020-11-05 15:31:40 +08:00
|
|
|
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',
|
2020-11-26 22:55:51 +08:00
|
|
|
'evtd',
|
2020-11-27 22:40:42 +08:00
|
|
|
'vdirs',
|
|
|
|
'seemly'
|
2020-11-05 15:31:40 +08:00
|
|
|
])
|
2019-12-30 13:15:14 +08:00
|
|
|
}
|