Refactor rollup.config.js

Co-authored-by: Shirasawa <764798966@qq.com>
Cherry-pick: 6a48fc9840dcac9d1740ffbe982ee4a4d5b8fd83
This commit is contained in:
yushijinhun 2020-01-01 01:33:24 +08:00
parent f969e7dbe0
commit add0c04c73
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4
1 changed files with 44 additions and 36 deletions

View File

@ -3,48 +3,56 @@ import typescript from "rollup-plugin-typescript2";
import resolve from "@rollup/plugin-node-resolve"; import resolve from "@rollup/plugin-node-resolve";
import license from "rollup-plugin-license"; import license from "rollup-plugin-license";
const base = { const umd = {
input: "src/skinview3d.ts", format: "umd",
output: [ name: "skinview3d",
{ indent: "\t",
format: "umd", globals: {
name: "skinview3d", "three": "THREE"
file: "dist/skinview3d.js", }
indent: "\t", };
globals: {
"three": "THREE" const es = {
} format: "es",
}, indent: "\t"
{ };
format: "es",
file: "dist/skinview3d.module.js", const licensePlugin = license({
indent: "\t" banner: `
}
],
external: [
"three"
],
plugins: [
resolve(),
typescript(),
license({
banner: `
skinview3d (https://github.com/bs-community/skinview3d) skinview3d (https://github.com/bs-community/skinview3d)
MIT License MIT License
` `
}) });
const base = {
input: "src/skinview3d.ts",
external: [
"three"
] ]
}; };
export default [ export default [
base, {
Object.assign({}, base, { ...base,
output: Object.assign({}, base.output[0], { file: "dist/skinview3d.min.js" }), output: [
plugins: (() => { { ...umd, file: "dist/skinview3d.js" },
const plugin = base.plugins.slice(); { ...es, file: "dist/skinview3d.module.js" }
plugin.splice(1, 0, terser()); ],
return plugin; plugins: [
})() resolve(),
}) typescript(),
licensePlugin
]
},
{
...base,
output: { ...umd, file: "dist/skinview3d.min.js" },
plugins: [
resolve(),
typescript(),
terser(),
licensePlugin
]
}
]; ];