Skip to content

Instantly share code, notes, and snippets.

@thescientist13
Last active January 22, 2018 14:53
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 thescientist13/f9be7826d0eca6eda0bdfef43d3fbf6d to your computer and use it in GitHub Desktop.
Save thescientist13/f9be7826d0eca6eda0bdfef43d3fbf6d to your computer and use it in GitHub Desktop.
Options for code splitting vendor dependencies w/webpack
/***** option A - separate vendor entry point in webpack config
// webpack config
module.exports = {
entry: {
index: './index.js',
vendor: './vendor.js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common'
})
]
}
// vendor.js
import lodash from 'lodash'
// index.js
import foo from 'bar'
/**** option B - import vendor in index.js, one webpack entry point
// webpack config
module.exports = {
entry: {
index: './index.js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common'
})
]
}
// vendor.js
import lodash from 'lodash'
// index.js
import './vendor.js'
import foo from 'bar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment