skinview3d/tools/rollup-util.js

65 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-01-06 11:47:07 +01:00
import uglify from "rollup-plugin-uglify";
import { minify } from "uglify-es";
import babel from "rollup-plugin-babel";
2018-01-15 11:46:30 +01:00
import resolve from "rollup-plugin-node-resolve";
2017-10-02 15:29:41 +02:00
let buildType = config => {
let options = {
2018-01-06 11:47:07 +01:00
input: "src/skinview3d.js",
2018-01-15 11:46:30 +01:00
output: [],
external:[
"three"
],
plugins: [
resolve()
]
2018-01-06 12:31:34 +01:00
};
switch (config.format) {
case "umd":
options.output.push({
2018-01-06 11:47:07 +01:00
format: "umd",
name: "skinview3d",
2018-01-15 12:06:46 +01:00
file: `build/skinview3d${config.postfix}.js`,
indent: "\t",
sourcemap: true,
globals: {
"three": "THREE"
}
2018-01-06 12:31:34 +01:00
});
break;
case "es":
options.output.push({
2018-01-06 11:47:07 +01:00
format: "es",
2018-01-15 12:06:46 +01:00
file: `build/skinview3d${config.postfix}.js`,
indent: "\t",
sourcemap: true,
2018-01-06 12:31:34 +01:00
});
break;
default:
throw `Unknown format: ${config.format}`;
}
2017-10-02 15:29:41 +02:00
if (config.babel) {
options.plugins.push(
babel({
2018-01-06 12:31:34 +01:00
exclude: "node_modules/**"
2017-10-02 15:29:41 +02:00
})
);
}
2018-01-06 12:31:34 +01:00
2017-10-02 15:29:41 +02:00
if (config.uglify) {
options.plugins.push(
uglify({
output: {
2018-01-06 12:31:34 +01:00
comments: "some"
2017-10-02 15:29:41 +02:00
}
}, minify)
);
}
return options;
};
export { buildType };