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

Code Splitting using Webpack or Webpack2 #1301

Open
ashuorg opened this issue Oct 18, 2016 · 12 comments
Open

Code Splitting using Webpack or Webpack2 #1301

ashuorg opened this issue Oct 18, 2016 · 12 comments

Comments

@ashuorg
Copy link

ashuorg commented Oct 18, 2016

how we can split the bundle using webpack or webpack2 into something like Vendor.js, Home.js, Others.js.

@isaachinman
Copy link

I am also interested if anyone has gotten code splitting working, particularly by route.

@Swapnilchavan18
Copy link

Anyone had solution on code splitting with webpack?

@bertho-zero
Copy link

You can look this pull request: #1298

For Webpack2 config you can look my repo here: https://github.com/bertho-zero/react-redux-universal-hot-example (without code splitting)
Using webpack 2 allow to you use System.import.

@Swapnilchavan18
Copy link

Is it to do code splitting as per routes? For ex each route in 1 bundle.js or some corelated routes in another bundle.js so that while app grows, page size does not increase too much? Can it solve by route?

@bertho-zero
Copy link

I just added code splitting here: src/routes.js.

@bertho-zero
Copy link

It split the code by routes, one route in 1 bundle:

screenshot from 2016-12-10 13 26 08

@bertho-zero
Copy link

bertho-zero commented Dec 18, 2016

I improved code splitting on my fork:
image

You can try it here: https://react-hot-example.herokuapp.com/

@githubjosh
Copy link

@bertho-zero i'm pretty sure your code splitting isn't outputting what you think.

The routes.js file is correctly loading page bundles, but your webpack entry file is client.js (which loads all routes a circular dependency): i.e. i think you're actually duplicating code in app bundle and your page-specific bundle. not tested

@isaachinman
Copy link

For anyone reading this trying to set up codesplitting, look into the webpack AggressiveMergingPlugin to remove duplicate code like @githubjosh is talking about.

@bertho-zero
Copy link

@githubjosh I think you're wrong, the size of the main bundle has decreased.
I have improved the codesplitting between the first and second image and the size of the main bundle has decreased again a bit.

@ashuorg
Copy link
Author

ashuorg commented Jun 3, 2017

@bertho-zero there is some problem with the server side rendering with your branch

@bertho-zero
Copy link

No, it's because the service worker serve files after the first load, you can do SHIFT+F5 for load from server (one time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants