build: Compress code in production environments

This commit is contained in:
Starbeamrainbowlabs 2019-01-20 23:22:09 +00:00
parent 6f7e682927
commit b9cbea5c96
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -9,13 +9,7 @@ import { terser } from "rollup-plugin-terser";
import postcss_import from 'postcss-import';
import postcss_copy from 'postcss-copy';
export default {
input: 'client_src/js/index.mjs',
output: {
file: 'app/app.js',
format: 'esm'
},
plugins: [
let plugins = [
resolve({
// use "module" field for ES6 module if possible
module: true, // Default: true
@ -62,13 +56,24 @@ export default {
extract: true,
sourceMap: true,
//minimize: true, // Causes an error at the moment for some reason
}),
})
];
// terser({
// numWorkers: os.cpus().length,
// compress: {
// ecma: 6
// }
// })
]
if(process.env.NODE_ENV == "production") {
console.log("[config] In production environment - minifying JS");
plugins.push(terser({
numWorkers: os.cpus().length,
compress: {
ecma: 6
}
}));
}
export default {
input: 'client_src/js/index.mjs',
output: {
file: 'app/app.js',
format: 'esm'
},
plugins
};