mirror of
https://github.com/idrawjs/idraw
synced 2026-05-23 09:38:22 +00:00
build: update rollup config
This commit is contained in:
parent
9a355881c4
commit
70d2b364b5
2 changed files with 27 additions and 12 deletions
|
|
@ -5,7 +5,7 @@
|
|||
"dev": "node ./scripts/dev.js",
|
||||
"dev:board": "node ./scripts/dev.js board",
|
||||
"dev:core": "node ./scripts/dev.js core",
|
||||
"build": "node ./scripts/build.js",
|
||||
"build": "NODE_ENV=production node ./scripts/build.js",
|
||||
"snapshot": "node ./scripts/build.js && node ./scripts/snapshot.js",
|
||||
"e2e": "mocha --exit ./__tests__/e2e.test.js",
|
||||
"init": "lerna bootstrap",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
const process = require('process');
|
||||
const path = require('path');
|
||||
const typescript = require('rollup-plugin-typescript2');
|
||||
const { terser } = require('rollup-plugin-terser');
|
||||
|
|
@ -26,6 +27,15 @@ for(let i = 0; i < packages.length; i++) {
|
|||
format: 'iife',
|
||||
plugins: []
|
||||
});
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
modules.push({
|
||||
input: resolveFile([pkg.dirName, 'src', 'index.ts']),
|
||||
output: resolveFile([pkg.dirName, 'dist', 'index.global.mini.js']),
|
||||
name: pkg.globalName,
|
||||
format: 'iife',
|
||||
plugins: []
|
||||
});
|
||||
}
|
||||
modules.push({
|
||||
input: resolveFile([pkg.dirName, 'src', 'index.ts']),
|
||||
output: resolveFile([pkg.dirName, 'dist', 'index.cjs.js']),
|
||||
|
|
@ -48,7 +58,7 @@ for(let i = 0; i < packages.length; i++) {
|
|||
}
|
||||
|
||||
|
||||
function createConfigItem(params) {
|
||||
function createConfigItem(params, opts = {}) {
|
||||
const { input, output, name, format, plugins = [], esModule, exports} = params;
|
||||
return {
|
||||
input: input,
|
||||
|
|
@ -74,25 +84,30 @@ function createConfigItem(params) {
|
|||
// cleanPlugin({
|
||||
// sourcemap: process.env.NODE_ENV === 'development',
|
||||
// }),
|
||||
// terser({
|
||||
// output: {
|
||||
// beautify: true,
|
||||
// // comments: false,
|
||||
// // indent_level: 2,
|
||||
// // quote_style: 3,
|
||||
// }
|
||||
// })
|
||||
cleanup({
|
||||
comments: 'none',
|
||||
}),
|
||||
]
|
||||
],
|
||||
...(opts.minify === true ? [
|
||||
terser({
|
||||
output: {
|
||||
beautify: false,
|
||||
comments: false,
|
||||
indent_level: 2,
|
||||
quote_style: 3,
|
||||
}
|
||||
})
|
||||
] : [])
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function createDevConfig(mods) {
|
||||
const configs = mods.map((mod) => {
|
||||
return createConfigItem(mod);
|
||||
const cfg = createConfigItem(mod, {
|
||||
minify: mod.output.endsWith('.mini.js'),
|
||||
});
|
||||
return cfg;
|
||||
});
|
||||
return configs;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue