skinview3d/tools/rollup-util.js

57 lines
946 B
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";
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",
indent: "\t",
2017-10-02 15:29:41 +02:00
sourcemap: true,
2018-01-06 11:47:07 +01:00
external: ["three"],
2017-10-02 15:29:41 +02:00
globals: {
2018-01-06 11:47:07 +01:00
three: "THREE"
2017-10-02 15:29:41 +02:00
},
2018-01-06 12:31:34 +01:00
output: [],
plugins: []
};
switch (config.format) {
case "umd":
options.output.push({
2018-01-06 11:47:07 +01:00
format: "umd",
name: "skinview3d",
2017-10-02 15:29:41 +02:00
file: `build/skinview3d${config.postfix}.js`
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-06 12:31:34 +01:00
file: `build/skinview3d${config.postfix}.js`
});
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 };