Refactor rollup.config.js
Co-authored-by: Shirasawa <764798966@qq.com> Cherry-pick: 6a48fc9840dcac9d1740ffbe982ee4a4d5b8fd83
This commit is contained in:
parent
f969e7dbe0
commit
add0c04c73
|
|
@ -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
|
||||||
|
]
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue