Last active
January 22, 2018 14:53
-
-
Save thescientist13/f9be7826d0eca6eda0bdfef43d3fbf6d to your computer and use it in GitHub Desktop.
Options for code splitting vendor dependencies w/webpack
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
/***** 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