-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
55 lines (53 loc) · 1.45 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
const defineConfig = require('rollup').defineConfig;
// 使用 require 语法导入 Babel 插件
const babel = require('rollup-plugin-babel');
// 使用 require 语法导入 Node Resolve 插件
const resolve = require('@rollup/plugin-node-resolve');
// 使用 require 语法导入 CommonJS 插件
const commonjs = require('@rollup/plugin-commonjs');
const { terser } = require('rollup-plugin-terser');
// 使用 require 语法动态引入 package.json
const pkg = require('./package.json');
// 动态设置打包名称
const libName = pkg.name;
const banner = `/*!
* ${libName}
* ${pkg.description}
* Author: ${pkg.author.name}
* Email: ${pkg.author.email}
* Repository: ${pkg.homepage}
* Version: ${pkg.version}
* License: ${pkg.license}
*/`;
module.exports = defineConfig({
input: 'src/cn-nm.js',
output: [
{
file: `dist/${libName}.cjs.js`,
format: 'cjs',
banner,
sourcemap: true,
},
{
file: `dist/${libName}.es.js`,
format: 'es',
banner,
sourcemap: true,
},
{
file: `dist/${libName}.umd.js`,
// UMD 格式,可以用于 Node 和浏览器等多个场景
format: 'umd',
name: libName,
exports: 'named',
banner,
sourcemap: true,
},
],
plugins: [
babel(),
resolve(),
commonjs(),
terser()
],
});