-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathrollup.default.config.js
84 lines (80 loc) · 1.92 KB
/
rollup.default.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import fs from 'fs';
import {
terser
} from 'rollup-plugin-terser';
import copy from 'rollup-plugin-copy';
import packageConfig from './package.json';
let formats = packageConfig.formats;
let builds = [];
let buildMain = function() {
builds.push({
input: 'src/main.js',
output: formats.map(format => {
var option = {
file: `dist/main/uqrcode.${format.name}.js`,
format: format.name,
exports: 'auto'
}
if (format.name === 'umd') {
option.name = 'UQRCode';
}
return option;
}),
plugins: [
terser(),
copy({
targets: [{
src: 'README.md',
dest: 'dist/main'
}, {
src: 'LICENSE.md',
dest: 'dist/main'
}],
verbose: true
})
] // 压缩代码,压缩后banner也会被移除,重新写个bannerConfig再次buildBanner
});
}
let buildPlugin = function(name, moduleName) {
let input = `plugin/${name}/plugin.js`;
if (!fs.existsSync(input)) {
return;
}
let output = formats.map(format => {
var option = {
file: `dist/plugin/${name}/uqrcode.plugin.${name}.${format.name}.js`,
format: format.name,
exports: 'auto'
}
if (format.name === 'umd') {
option.name = moduleName;
}
return option;
});
let plugins = [
copy({
targets: [{
src: `plugin/${name}/README.md`,
dest: `dist/plugin/${name}`
}, {
src: `LICENSE.md`,
dest: `dist/plugin/${name}`
}],
verbose: true
})
];
builds.push({
input,
output,
plugins
});
}
buildMain();
buildPlugin('round', 'UQRCodePluginRound');
buildPlugin('liquid', 'UQRCodePluginLiquid');
buildPlugin('words', 'UQRCodePluginWords');
buildPlugin('25d', 'UQRCodePlugin25D');
buildPlugin('art', 'UQRCodePluginArt');
buildPlugin('colorful', 'UQRCodePluginColorful');
buildPlugin('poster', 'UQRCodePluginPoster');
export default builds;