Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack Multi Entry Common Vendor #2191

Closed
ravilution opened this issue Mar 16, 2016 · 3 comments
Closed

Webpack Multi Entry Common Vendor #2191

ravilution opened this issue Mar 16, 2016 · 3 comments
Labels

Comments

@ravilution
Copy link

I have an application with multi entry points. But all entry points use same 3rd party libraries. I want to have those 3rd party libraries alone in one separate file. When I followed the steps in the documentation, it moves my application code also into the 3rd vendor chunk file.

entry: {
index: __dirname + "/entry1.js",
app: __dirname + "/entry2.js",
vendor: ["axios", "react-router", "react", "react-dom"]
},
output: {
path: __dirname + "/build",
filename: "[name]-[hash].js"
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("vendor", "[name]-[hash].js")
]

Below is the webpack output

Hash: 78d489a6e4aec65292b2
Version: webpack 1.12.14
Time: 8161ms
Asset Size Chunks Chunk Names
vendor-78d489a6e4aec65292b2.js 925 kB 0 [emitted] vendor
index-78d489a6e4aec65292b2.js 1.87 kB 1 [emitted] index
app-78d489a6e4aec65292b2.js 1.41 kB 2 [emitted] app
index-78d489a6e4aec65292b2.css 83 bytes 1 [emitted] index
vendor-78d489a6e4aec65292b2.js.map 1.05 MB 0 [emitted] vendor
index-78d489a6e4aec65292b2.js.map 2.3 kB 1 [emitted] index
index-78d489a6e4aec65292b2.css.map 107 bytes 1 [emitted] index
app-78d489a6e4aec65292b2.js.map 1.76 kB 2 [emitted] app
index.html 370 bytes [emitted]
app.html 311 bytes [emitted]
[0] multi vendor 64 bytes {0} [built]

  • 258 hidden modules
    Child html-webpack-plugin for "index.html":
  • 3 hidden modules
    Child html-webpack-plugin for "app.html":
  • 3 hidden modules
    Child extract-text-webpack-plugin:
  • 2 hidden modules

http://stackoverflow.com/questions/36001871/webpack-multi-entry-common-vendor

@ravilution
Copy link
Author

@bebraw Not sure if this is just a question or a bug?

@bebraw bebraw added bug and removed question labels Mar 22, 2016
@bebraw
Copy link
Contributor

bebraw commented Mar 22, 2016

Upgraded to bug based on the comments at the Stack Overflow question. Thanks.

@sokra
Copy link
Member

sokra commented Mar 24, 2016

It moves common modules (modules that are in app and index) also into the vendor chunk, because this is the CommonChunkPlugin and creating a chunk which your common modules it what it does. see documentation.

See this example if you want to create an explicit vendor chunk: https://github.com/webpack/webpack/tree/master/examples/explicit-vendor-chunk

@sokra sokra closed this as completed Mar 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants