-
Notifications
You must be signed in to change notification settings - Fork 74
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 doesn't work in production (because only main chunk gets copied to meteor folder) #138
Comments
Anytime Meteor can't find the requested file, it just serves up the index page, which is not a great idea, in my opinion. That happens if I navigate to the meteor port instead of the webpack port. Since this skeleton project isn't configured to put the Webpack bundle at a path like that, it seems you've tweaked the configuration somehow. Also, you unfortunately need to use |
Hmm. Ok, so what you're saying is that it should work but my configuration is off? I have modified it but I'm not sure what I would have changed to do that. I'll clone your repo again and put together as basic of a test as possible and report back here. Thanks. (And yeah, I actually do have the .default in my code. I forgot to include it above.) |
Ok. The problem is with
I'll include my deploy steps at the end of this post.
Create Sample.jsx in the components folder:
Modify App.jsx to look like this:
My deploy steps are:
I'm running dev and building with Node 5.10.0 and NPM 3.8.3. |
Ah, the reason is that the script doesn't copy anything but the main client bundle into the meteor folder. It works in dev mode because all bundles are being served up straight from The webpack-meteor-tools branch might work with code splitting in prod. I know at least that in my own project, where I'm using the load-entry-chunks-only branch of webpack-meteor-tools, code splitting works in prod. I haven't had time to clean this up for general use yet. |
Ok. That makes a lot of sense now. I assume using webpack-meteor-tools would be a better approach but as a small workaround would it not work to modify the In my example above I noticed that webpack produced the So I'm going to modify |
Yes, certainly you can do that as well. Probably that would be a good stopgap fix for this project skeleton too |
So would you use this project skeleton for a production app or are there other resources you would focus on? You mentioned webpack-meteor-tools and I have tried webpack:webpack but it's very slow when developing. (BTW, I love how fast HMR, especially in this project skeleton.) Anyways, I'll include my predeploy.js script here in case someone else stumbles upon this problem. I'm not sure if it's PR worthy.
|
In my production projects I'm using the |
Awesome! Well. I guess that closes this bug, at least for now. Thanks! |
Well, I'll leave it open, because while you have a solution, the current master still doesn't support this use case. Thanks for bringing it up! |
Hey @darkadept, I came out with a much better app skeleton that works with Meteor 1.4: jedwards1211/crater. Check it out! |
Awesome! I'm super excited about this! I'll check it out asap. I hope I can help with finding bugs, etc. |
The following works fine in dev mode, but does not work in prod mode.
I'm using react-router with getComponent to dynamically load a component when the route changes using the following code:
Webpack successfully compiles my
TestComponent
as a separate chunk, usually0.client.bundle.js
or1.client.bundle.js
. When I try to browse to the test path (/test
) I get the following error in my browser console:I guess Webpack is telling the browser to load this chunk on demand. The problem is that Meteor does not serve this chunk as JS but as an HTML page. This is the HTML it serves:
So Meteor is taking over and wrapping my request for the chunk in it's own Meteor page. The chunk code is actually in the
/a25388218b6661007b61be8836458c55ccf2d96a.js?meteor_js_resource=true
file.Is there a way to get Webpack to ask for the correct file or for Meteor to serve up the chunk correctly?
The text was updated successfully, but these errors were encountered: