Setup production optimizations

This commit is contained in:
SleepWalker 2019-11-09 13:52:41 +02:00
parent c1c9d46fda
commit 0acf1a8d97

View File

@ -14,7 +14,6 @@ const SUPPORTED_LANGUAGES = Object.keys(require('./src/i18n/index.json'));
const localeFlags = require('./src/components/i18n/localeFlags').default; const localeFlags = require('./src/components/i18n/localeFlags').default;
const rootPath = path.resolve('./src'); const rootPath = path.resolve('./src');
const outputPath = path.join(__dirname, 'dist'); const outputPath = path.join(__dirname, 'dist');
const packageJson = require('./package.json');
let config = {}; let config = {};
try { try {
@ -246,10 +245,6 @@ if (isProduction) {
}); });
webpackConfig.plugins.push( webpackConfig.plugins.push(
// TODO: configure optimisations
// new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js?[hash]'),
// new webpack.optimize.DedupePlugin(),
// new webpack.optimize.UglifyJsPlugin(),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: '[name].css?[hash]', filename: '[name].css?[hash]',
chunkFilename: '[id].css?[hash]', chunkFilename: '[id].css?[hash]',
@ -258,13 +253,19 @@ if (isProduction) {
webpackConfig.devtool = 'hidden-source-map'; webpackConfig.devtool = 'hidden-source-map';
// TODO: remove me after migration webpackConfig.optimization = {
// With this code we have tried to configure which deps have go into the 'vendor.js' chunk moduleIds: 'hashed',
// const ignoredPlugins = ['flag-icon-css']; runtimeChunk: 'single',
splitChunks: {
// webpackConfig.entry.vendor = Object.keys(packageJson.dependencies).filter( cacheGroups: {
// (module) => !ignoredPlugins.includes(module) vendor: {
// ); test: (m) => String(m.context).includes('node_modules') && !String(m.context).includes('flag-icon-css'),
name: 'vendors',
chunks: 'all',
},
},
}
};
} else { } else {
webpackConfig.plugins.push( webpackConfig.plugins.push(
new webpack.DllReferencePlugin({ new webpack.DllReferencePlugin({