question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack for server build: can we limit to 1 chunk?

See original GitHub issue

My setup includes a webpack build for the client and the server.

I’ve looked through the SSR example and it shows that you should be using LoadablePlugin on both the client and server builds. So you get 2 sets of chunks + stats. It then uses the ChunkExtractor to get the entry point.

But this seems counterintuitive, why would the server need to handle loading multiple chunks? It really should only operate synchronously and collect information about what chunks are necessary for the client to pass down. In that case, there’s only one entry point, so you don’t even need the second ChunkExtractor.

react-universal-component has an approach that limits to a single chunk:

new webpack.optimize.LimitChunkCountPlugin({
  maxChunks: 1,
}),

Doing this and removing LoadablePlugin from the server build seems to operate fine, but I just wanted to confirm my understanding here is correct.

If this is a good approach, I’m happy to update docs/examples.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
xtroncodecommented, Nov 8, 2019

I am using the approach you have mentioned in a reactjs.net application and it has been working fine

0reactions
rtymchykcommented, Nov 18, 2019

I’ll go ahead and close this, it doesn’t sound like there’s an actionable here for docs/examples. I personally would recommend sticking to a simpler setup than trying to optimize for boot up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack for server build: can we limit to 1 chunk? #456 - GitHub
It really should only operate synchronously and collect information about what chunks are necessary for the client to pass down. In that case, ......
Read more >
LimitChunkCountPlugin - webpack
Limit the maximum number of chunks using a value greater than or equal to 1 . Using 1 will prevent any additional chunks...
Read more >
The 100% correct way to split your chunks with Webpack
The idea behind bundle splitting is pretty simple. If you have one giant file, and change one line of code, the user must...
Read more >
Minimize only one Webpack chunk - Stack Overflow
Check if you are creating production build. Then, you can name the chunks you want to create as minified with".min.js" extension. Rest ...
Read more >
Using Webpack with React, Pt. 1 - Toptal
There are several optimization techniques that we can use in our build process. We will begin with code minification, a process by which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found