Refactor rollup.config.js

Co-authored-by: Shirasawa <764798966@qq.com>
This commit is contained in:
yushijinhun 2020-01-01 01:33:24 +08:00
parent db1884e782
commit ff07a9510c
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",
output: [
{
format: "umd", format: "umd",
name: "skinview3d", name: "skinview3d",
file: "dist/skinview3d.js",
indent: "\t", indent: "\t",
globals: { globals: {
"three": "THREE" "three": "THREE"
} }
}, };
{
const es = {
format: "es", format: "es",
file: "dist/skinview3d.module.js",
indent: "\t" indent: "\t"
} };
],
external: [ const licensePlugin = license({
"three"
],
plugins: [
resolve(),
typescript(),
license({
banner: ` 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
]
}
]; ];