-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcjs_config_min_es6.js
64 lines (62 loc) · 1.81 KB
/
cjs_config_min_es6.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import path from 'path';
import resolve from 'rollup-plugin-node-resolve';
import common from 'rollup-plugin-commonjs';
import json from '@rollup/plugin-json';
import replace from '@rollup/plugin-replace';
import {terser} from 'rollup-plugin-terser';
import os from 'os';
const cpuNums = os.cpus().length;
export default {
input: {
main: path.resolve(__dirname, './main/index.js'),
vendor: path.resolve(__dirname, './utils/index.js')
},
external: [
'jquery',
'lodash'
],
plugins: [
resolve({
mainFields: ['module', 'main'],
browser: true
}),
json(),
common({
include: 'node_modules/**', // 包括
exclude: [], // 排除
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
terser({
output: {
comments: false
},
include: [/^.+\.js$/], // 包括
exclude: ['node_modules/**'], // 排除
numWorkers: cpuNums,
sourcemap: true
})
],
output: {
dir: path.resolve(__dirname, 'dist/cjs-min-es6'),
format: 'cjs',
name: 'rollupTest',
entryFileNames: '[name]-[hash]-[format].min.js',
chunkFileNames: '[name]-[hash]-[format].min.js',
compact: true,
banner: '/* JohnApache JSLib */',
footer: '/* CopyRight @ 2019*/',
intro: '/* this is a introduction */',
outro: '/* this is an another introduction */',
extend: false,
sourcemap: true,
sourcemapPathTransform: (relativePath) => {
return relativePath;
},
strictDeprecations: false
},
manualChunks: {
'myLib': [path.resolve(__dirname, './myLib/index.js')]
}
}