-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathrollup.banner.config.js
90 lines (83 loc) · 2.61 KB
/
rollup.banner.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
85
86
87
88
89
90
import fs from 'fs';
import packageConfig from './package.json';
let formats = packageConfig.formats;
let builds = [];
let getBannerMain = function() {
return `//---------------------------------------------------------------------
// uQRCode二维码生成插件 v${packageConfig.version}
//
// uQRCode是一款基于Javascript环境开发的二维码生成插件,适用所有Javascript运行环境的前端应用和Node.js。
//
// Copyright (c) Sansnn uQRCode All rights reserved.
//
// Licensed under the Apache License, Version 2.0.
// http://www.apache.org/licenses/LICENSE-2.0
//
// github地址:
// https://github.com/Sansnn/uQRCode
//
// npm地址:
// https://www.npmjs.com/package/uqrcodejs
//
// uni-app插件市场地址:
// https://ext.dcloud.net.cn/plugin?id=1287
//
// 复制使用请保留本段注释,感谢支持开源!
//
//---------------------------------------------------------------------
`;
}
let getBannerFormat = function(format) {
return `//---------------------------------------------------------------------
// 当前文件格式为 ${format.name},${format.description}
// 如需在其他环境使用,请获取环境对应的格式文件
// 格式说明:
${formats.map(f => `// ${f.name} - ${f.description}`).join('\n')}
//---------------------------------------------------------------------
`;
}
let buildMain = function() {
formats.map(format => {
let option = {
input: `dist/main/uqrcode.${format.name}.js`,
output: {
file: `dist/main/uqrcode.${format.name}.js`,
banner: getBannerMain() + '\n' + getBannerFormat(format),
compact: true
}
}
if (format.name === 'umd') {
option.context = 'typeof window !== "undefined" ? window : global';
}
builds.push(option);
});
}
let buildPlugin = function(name, title) {
formats.forEach(format => {
let input = `dist/plugin/${name}/uqrcode.plugin.${name}.${format.name}.js`;
if (!fs.existsSync(input)) {
return;
}
let option = {
input,
output: {
file: `dist/plugin/${name}/uqrcode.plugin.${name}.${format.name}.js`,
banner: getBannerMain() + '\n' + getBannerFormat(format),
compact: true
}
}
if (format.name === 'umd') {
option.context = 'typeof window !== "undefined" ? window : global';
}
builds.push(option);
});
}
buildMain();
buildPlugin('round', '圆点码');
buildPlugin('liquid', '液态码');
buildPlugin('words', '文字码');
buildPlugin('25d', '2.5D码');
buildPlugin('art', '艺术码');
buildPlugin('colorful', '炫彩码');
buildPlugin('poster', '海报');
export default builds;