CommonsChunkPlugin is a webpack plugin that helps you bundle common code among your modules into separate bundles.
Questions tagged [commonschunkplugin]
72 questions
4
votes
1 answer
How to use one vendor chunk file (webpack) for multiple react projects
I have different gits with different react applications. Where every application should use the same vendors chunk file with external packages (React, ReactDOM ...)
Projects setup:
Project 1 (git)
/dist/...
/src/...
…

Martin
- 3,096
- 1
- 26
- 46
3
votes
1 answer
Webpack: How to migrate CommonsChunkPlugin (wp3) to optimization.splitChunks (wp4)?
I'm trying to migrate to webpack4 from 3 and I'm having a really hard time migrating CommonsChunkPlugin.
On WP3, I have the following simplified configuration:
const entries = {
client: './src/index.js',
common1: ['lodash'],
common2: ['react',…

fabiomcosta
- 1,105
- 1
- 8
- 10
3
votes
1 answer
Webpack migration 3 -> 4: Error: Cannot find module 'webpack/lib/optimize/CommonsChunkPlugin'
I'm trying to migrate from webpack 3 to webpack 4.
The issue I have is with CommonsChunkPlugin, when I try to run webpack (npm run webpack-dev-server -- --config config/webpack.dev.js), I have the following error:
module.js:529
throw err;
…

Tonio
- 4,082
- 4
- 35
- 60
3
votes
1 answer
What does 'Chunks' mean in CLI output?
Command I run:
$ webpack --config webpack.config.js -p --progress
This is the result I get. What do chunks mean? Why do they change sometimes?
If I understand it right, the more chunks the better.
But I can't see same amount of files. If I have…

Green
- 28,742
- 61
- 158
- 247
3
votes
1 answer
Webpack and CommonsChunkPlugin, separating node_modules out for each async chunk
I have successfully got Webpack and the CommonsChunkPlugin to split my code in two - one bundle with my codebase, and one with everything imported from node_modules. That was the relatively easy bit.
The next thing I'm trying to achieve in my app is…

Gav
- 431
- 5
- 12
3
votes
0 answers
How minChunks in CommonsChunkPlugin affect the custom css style rendering?
React CSS style is rendering later than custom CSS style, which is somehow dependent on minChunks.
new webpack.optimize.CommonsChunkPlugin({
name: "common",
minChunks: function(module, count) {
return…

Ashutosh Ranjan
- 642
- 5
- 12
3
votes
2 answers
Webpack - React Router V4 - code splitting duplicate modules in async chunks
The main problem is while code splitting with react-routerV4 and then webpack 2, I have modules that are in several chunks that I can't get to the main one.
My configuration is as follow :
Webpack 2.2.1
React-route 4.1.1
I'm using the code…
3
votes
1 answer
Extract common styles with ExtractTextPlugin and CommonsChunkPlugin
I'm trying to extract common chunk from my css according wiki section. I know that this docs is for webpack 1 but for webpack 2 seems like there is no corresponding example yet. I use the following webpack config:
module.exports = {
context:…

Invis1ble
- 1,295
- 2
- 17
- 35
3
votes
1 answer
Serviceworker Chunk with CommonsChunkPlugin doesn't work, webpackJsonp is not defined
I'm trying to create a serviceworker chunk (sw.js) with webpack2 using the CommonsChunkPlugin but when trying to register /sw.js as a serviceworker I get the error Uncaught ReferenceError: webpackJsonp is not defined.
Apparently webpackJsonp is for…

raphi011
- 502
- 1
- 6
- 23
2
votes
1 answer
How to upgrade Webpack 3 CommonsChunkPlugin config to Webpack 4 splitChunks while maintaining same behaviour for this case?
I'm trying to migrate from Webpack 3 to 4, and that requires me to change from using CommonsChunkPlugin to splitChunks. But I'm struggling to maintain the same behaviour.
My Webpack 3 code:
webpack.config.js
entry: {
vendor: ['jquery',…

Henry Yang
- 2,283
- 3
- 21
- 38
2
votes
1 answer
How to prevent commonsChunkPlugin from injecting the chunks into html
I am using preload-webpack-plugin along with the commonschunkplugin for webpack. My webpack version is 3.
Now the issue is that using the preloadplugin, I am already prefetching the async routes in my vue application. But since commonschunkplugin is…

Agniva De Sarker
- 778
- 2
- 12
- 22
2
votes
1 answer
Webpack multiple chunks include same dependency
I want to have some dependencies in different chunks so client.js would be smaller. webpack 4.16.5
Why I get same code included to several chunks? What's missing?
const path = require('path');
const webpack = require('webpack');
const…

Lukas Liesis
- 24,652
- 10
- 111
- 109
2
votes
0 answers
Exclude entry from webpack CommonsChunkPlugin
I have a multi-page website. Each page has its own entry point. I am using the CommonsChunkPlugin to extract shared libraries into a common js file that is included on all of my pages.
I have one page that is different. This page runs some…

Brian Ball
- 12,268
- 3
- 40
- 51
2
votes
1 answer
Webpack 4 - What is the splitChunks equivalent to minChunk: Infinity
In webpack 3, we used to be able to have a dependency, and all of it's dependencies grouped together in a "common chunk" by using:
new webpack.optimize.CommonsChunkPlugin({
name: 'common-init',
minChunks: Infinity
})
In…

jms
- 49
- 1
- 8
2
votes
0 answers
How to make multiple page webpack build with 3 entry point without repetion of config code?
I need to create a multiple web app with 10 pages and 3 entry point. Do I should create 11 HtmlWebpackPlugin and write chunks what I want to use in every HTML files.
My file tree:
In result, I want to see something like that:
The version of…

Maxim Soltyk
- 73
- 1
- 1
- 8