Refactor rollup.config.js
Co-authored-by: Shirasawa <764798966@qq.com>
This commit is contained in:
parent
db1884e782
commit
ff07a9510c
|
@ -3,48 +3,56 @@ import typescript from "rollup-plugin-typescript2";
|
|||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import license from "rollup-plugin-license";
|
||||
|
||||
const base = {
|
||||
input: "src/skinview3d.ts",
|
||||
output: [
|
||||
{
|
||||
format: "umd",
|
||||
name: "skinview3d",
|
||||
file: "dist/skinview3d.js",
|
||||
indent: "\t",
|
||||
globals: {
|
||||
"three": "THREE"
|
||||
}
|
||||
},
|
||||
{
|
||||
format: "es",
|
||||
file: "dist/skinview3d.module.js",
|
||||
indent: "\t"
|
||||
}
|
||||
],
|
||||
external: [
|
||||
"three"
|
||||
],
|
||||
plugins: [
|
||||
resolve(),
|
||||
typescript(),
|
||||
license({
|
||||
banner: `
|
||||
const umd = {
|
||||
format: "umd",
|
||||
name: "skinview3d",
|
||||
indent: "\t",
|
||||
globals: {
|
||||
"three": "THREE"
|
||||
}
|
||||
};
|
||||
|
||||
const es = {
|
||||
format: "es",
|
||||
indent: "\t"
|
||||
};
|
||||
|
||||
const licensePlugin = license({
|
||||
banner: `
|
||||
skinview3d (https://github.com/bs-community/skinview3d)
|
||||
|
||||
MIT License
|
||||
`
|
||||
})
|
||||
});
|
||||
|
||||
const base = {
|
||||
input: "src/skinview3d.ts",
|
||||
external: [
|
||||
"three"
|
||||
]
|
||||
};
|
||||
|
||||
export default [
|
||||
base,
|
||||
Object.assign({}, base, {
|
||||
output: Object.assign({}, base.output[0], { file: "dist/skinview3d.min.js" }),
|
||||
plugins: (() => {
|
||||
const plugin = base.plugins.slice();
|
||||
plugin.splice(1, 0, terser());
|
||||
return plugin;
|
||||
})()
|
||||
})
|
||||
{
|
||||
...base,
|
||||
output: [
|
||||
{ ...umd, file: "dist/skinview3d.js" },
|
||||
{ ...es, file: "dist/skinview3d.module.js" }
|
||||
],
|
||||
plugins: [
|
||||
resolve(),
|
||||
typescript(),
|
||||
licensePlugin
|
||||
]
|
||||
},
|
||||
{
|
||||
...base,
|
||||
output: { ...umd, file: "dist/skinview3d.min.js" },
|
||||
plugins: [
|
||||
resolve(),
|
||||
typescript(),
|
||||
terser(),
|
||||
licensePlugin
|
||||
]
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue