-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathrollup.config.js
55 lines (51 loc) · 1.13 KB
/
rollup.config.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
import commonjs from 'rollup-plugin-commonjs';
import typescript from 'rollup-plugin-typescript';
// import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
const external = Object.keys(pkg.peerDependencies);
const env = process.env.BUILD_ENV;
console.log(`env is ${env}`);
const distFileName = 'hel-micro';
const globalName = 'HelMicro';
const env2outputConf = {
commonjs: {
format: 'cjs',
dir: 'lib',
},
es: {
format: 'es',
dir: 'es',
},
development: {
format: 'umd',
file: `dist/${distFileName}.js`,
name: globalName,
},
production: {
format: 'umd',
file: `dist/${distFileName}.min.js`,
name: globalName,
},
};
const config = {
input: 'src/index.ts',
external,
output: {
...env2outputConf[env],
exports: 'named',
globals: {
'hel-micro-core': 'HelMicroCore',
'hel-html-parser': 'HelHtmlParser',
},
},
plugins: [
commonjs(),
typescript({
// exclude: 'node_modules/**',
typescript: require('typescript'),
}),
// 如不想压缩,不配置 terser() 即可
// terser(),
],
};
export default config;