-
Notifications
You must be signed in to change notification settings - Fork 530
Expand file tree
/
Copy pathrollup.config.js
More file actions
47 lines (45 loc) · 1.01 KB
/
rollup.config.js
File metadata and controls
47 lines (45 loc) · 1.01 KB
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
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { babel } from '@rollup/plugin-babel';
import { readFileSync } from 'fs';
import terser from '@rollup/plugin-terser'
// 读取 package.json 中的版本号
const packageInfo = JSON.parse(readFileSync('./package.json', 'utf8'));
export default {
input: 'src/meting.js',
output: [
{
file: 'lib/meting.esm.js',
format: 'es'
},
{
file: 'lib/meting.js',
format: 'cjs',
exports: 'auto'
}
],
plugins: [
nodeResolve({
preferBuiltins: true
}),
babel({ babelHelpers: 'bundled' }),
// 版本号注入插件
{
name: 'inject-version',
transform(code, id) {
if (id.endsWith('src/meting.js')) {
return code.replace('__VERSION__', packageInfo.version);
}
return null;
}
},
terser({
format: {
comments: false
},
compress: {
drop_console: false
}
})
],
external: ['crypto', 'url', 'fs', 'path']
};