Skip to content

Instantly share code, notes, and snippets.

@afgomez
Created May 19, 2018 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afgomez/3357e82faf520aa4cd7e7c7d1448e92b to your computer and use it in GitHub Desktop.
Save afgomez/3357e82faf520aa4cd7e7c7d1448e92b to your computer and use it in GitHub Desktop.
Webpack 3 & 4 config equivalents
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
one: './src/one.js',
two: './src/two.js',
three: './src/three.js',
},
output: {
path: path.resolve(__dirname, 'out'),
filename: '[name].js',
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.js',
minChunks: 2,
}),
],
};
const path = require('path');
module.exports = {
// New
mode: process.env.NODE_ENV || 'development',
entry: {
one: './src/one.js',
two: './src/two.js',
three: './src/three.js',
},
output: {
path: path.resolve(__dirname, 'out'),
filename: '[name].js',
},
optimization: {
// Force webpack to include it's runtime in the `vendor` chunk.
// Otherwise it adds a runtime per entry point.
runtimeChunk: {
name: 'vendor',
},
// CommonsChunkPlugin
splitChunks: {
name: 'vendor',
filename: 'vendor.js',
chunks: 'all',
minSize: 1,
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment