Created
May 19, 2018 09:16
-
-
Save afgomez/3357e82faf520aa4cd7e7c7d1448e92b to your computer and use it in GitHub Desktop.
Webpack 3 & 4 config equivalents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
}), | |
], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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