gistlib
There are several ways to optimize webpack for performance:
index.tsxconst UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = { optimization: { minimizer: [new UglifyJSPlugin(), new TerserPlugin()] } }; 217 chars9 lines
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = { optimization: { minimizer: [new UglifyJSPlugin(), new TerserPlugin()] } };
index.tsxmodule.exports = { optimization: { splitChunks: { chunks: 'all' } } }; 89 chars8 lines
module.exports = { optimization: { splitChunks: { chunks: 'all' } } };
index.tsxconst webpack = require('webpack'); module.exports = { plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }) ] }; 173 chars10 lines
const webpack = require('webpack'); module.exports = { plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }) ] };
index.tsximport('lodash').then(_ => { // Use Lodash here }); 54 chars4 lines
import('lodash').then(_ => { // Use Lodash here });
index.tsxmodule.exports = { output: { filename: '[name].[chunkhash].js' }, plugins: [ new webpack.HashedModuleIdsPlugin(), new webpack.optimize.ModuleConcatenationPlugin(), new webpack.NoEmitOnErrorsPlugin(), new webpack.NamedModulesPlugin(), new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', minChunks: ({ resource }) => ( resource && resource.indexOf('node_modules') !== -1 && resource.match(/\.js$/) ), }), new webpack.optimize.CommonsChunkPlugin({ name: 'manifest', minChunks: Infinity, }), ], devtool: '#source-map', }; 624 chars25 lines
module.exports = { output: { filename: '[name].[chunkhash].js' }, plugins: [ new webpack.HashedModuleIdsPlugin(), new webpack.optimize.ModuleConcatenationPlugin(), new webpack.NoEmitOnErrorsPlugin(), new webpack.NamedModulesPlugin(), new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', minChunks: ({ resource }) => ( resource && resource.indexOf('node_modules') !== -1 && resource.match(/\.js$/) ), }), new webpack.optimize.CommonsChunkPlugin({ name: 'manifest', minChunks: Infinity, }), ], devtool: '#source-map', };
gistlibby LogSnag