1 Star 0 Fork 1

hawkc/bpmn-js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.js 2.44 KB
一键复制 编辑 原始数据 按行查看 历史
Nico Rehwaldt 提交于 2019-07-31 13:03 . chore(project): minify using terser
import { terser } from 'rollup-plugin-terser';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import license from 'rollup-plugin-license';
import replace from 'rollup-plugin-replace';
import {
readFileSync
} from 'fs';
import pkg from './package.json';
const outputDir = 'dist';
const distros = [
{
input: 'Viewer',
output: 'bpmn-viewer'
},
{
input: 'NavigatedViewer',
output: 'bpmn-navigated-viewer'
},
{
input: 'Modeler',
output: 'bpmn-modeler'
}
];
const configs = distros.reduce(function(configs, distro) {
const {
input,
output
} = distro;
return [
...configs,
{
input: `./lib/${input}.js`,
output: {
name: 'BpmnJS',
file: `${outputDir}/${output}.development.js`,
format: 'umd'
},
plugins: pgl([
banner(output)
])
},
{
input: `./lib/${input}.js`,
output: {
name: 'BpmnJS',
file: `${outputDir}/${output}.production.min.js`,
format: 'umd'
},
plugins: pgl([
banner(output, true),
terser({
output: {
comments: /license|@preserve/
}
})
])
}
];
}, []);
export default configs;
// helpers //////////////////////
function banner(bundleName, minified) {
const bannerName = (
minified
? 'banner-min'
: 'banner'
);
const bannerTemplate = readFileSync(`${__dirname}/resources/${bannerName}.txt`, 'utf8');
const banner = processTemplate(bannerTemplate, {
version: pkg.version,
date: today(),
name: bundleName
});
return license({
banner
});
}
function pgl(plugins=[]) {
return [
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
nodeResolve({
mainFields: [
'browser',
'module',
'main'
]
}),
commonjs(),
json(),
...plugins
];
}
function pad(n) {
if (n < 10) {
return '0' + n;
} else {
return n;
}
}
function today() {
const d = new Date();
return [
d.getFullYear(),
pad(d.getMonth() + 1),
pad(d.getDate())
].join('-');
}
function processTemplate(str, args) {
return str.replace(/\{\{\s*([^\s]+)\s*\}\}/g, function(_, n) {
var replacement = args[n];
if (!replacement) {
throw new Error('unknown template {{ ' + n + '}}');
}
return replacement;
});
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Hawkc/bpmn-js.git
git@gitee.com:Hawkc/bpmn-js.git
Hawkc
bpmn-js
bpmn-js
master

搜索帮助