2018-03-07 16:09:43 -05:00
|
|
|
// vim: set et ts=2 sw=2:
|
|
|
|
//
|
|
|
|
|
2018-03-07 20:34:08 -05:00
|
|
|
const webpack = require('webpack');
|
2018-03-07 16:09:43 -05:00
|
|
|
const NVRSettings = require('./NVRSettings');
|
2018-03-07 20:34:08 -05:00
|
|
|
const baseConfig = require('./base.config.js');
|
|
|
|
|
|
|
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
|
|
|
|
2018-03-07 16:09:43 -05:00
|
|
|
module.exports = (env, args) => {
|
|
|
|
const settingsObject = new NVRSettings(env, args);
|
|
|
|
const nvrSettings = settingsObject.settings;
|
|
|
|
|
|
|
|
return settingsObject.webpackMerge(baseConfig, {
|
|
|
|
optimization: {
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
default: {
|
|
|
|
minChunks: 2,
|
|
|
|
priority: -20,
|
|
|
|
},
|
|
|
|
commons: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: 'vendor',
|
|
|
|
chunks: 'all',
|
|
|
|
priority: -10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
|
|
}),
|
|
|
|
new CleanWebpackPlugin([nvrSettings.dist_dir], {
|
|
|
|
root: nvrSettings._paths.project_root,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
};
|