-
Notifications
You must be signed in to change notification settings - Fork 27
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
Play nice with server pre-rendering? #19
Comments
You're right, there's no way to specify different chunks the messages should go to. All the messages (and other locale specific compiled data) go to the language chunk. The architecture envisioned by this plugin assumes you have an app.js completely independent of locale data. The locale part comes from a separate i18n/.js file that extends the app with such locale. Please, correct me if I'm wrong, but I understood you want an app.js (entry chunk) that has locale code (pre-rendered views), so you have n different app.js'es (one per supported locale) that are dynamically generated/served by your server and on top of it you still have language chunks for other non-pre-rendered views. Please, could you include a reduced example that demonstrates this? Additionally (or even alternatively) to help me clarify what you need, could you provide with two things? (a) Assuming we have the feature you're looking for implemented, how would the globalize-webpack config look like? (b) Also assuming we have the feature you're looking for implemented, what content would go in each of the final files? Thanks |
I started to answer and ended up writing a novel...so i just went ahead and implemented what i wanted instead ;) if you take a look at my fork or the latest submission to my pull request #17 i've added a new class to deal with prerendering, and an example of how to use it. essentially you opt into this new behavior by specifying 'target: "node"' in your webpack config. when that's specified the plugin will remove the globalize runtime from the main bundle and dump it into each of the locale bundles, replace each instance of 'require("globalize")' in the main bundle with "require(locale)" and then wraps the whole main bundle in a function which accepts a locale variable. so on the server you would do something like: var appPath = path.join(__dirname, "./dist/prerender/app.js"); the example in my fork has a simple node server that dumps will pull the "accept-language" header form the request and dump the language specific messages to the console. |
Hi, I would like to know if it is possible to generate separate bundle for each locale, that is exactly what I need. Similiar behavior has https://github.com/webpack-contrib/i18n-webpack-plugin. It just replaces function invocations with translated string. |
it's been a long time...i created my fork the way i wanted it back then and have been using it ever since...don't really remember the details. i did a tree on my production directory structure and removed a bunch of extraneous files, it looks like: |
@EXC-BAD-ACCESS |
it appears that there's no way to specify that the messages should be included in the entry chunk instead of in separate language specific chunks. typically (as in i don't know how else to do it) if an app is broken up into a pre-rendered server side version and a downloadable client side version (much better description here) then the server version is one big bundle that contains everything and only the client version is broken up into multiple bundles.
if there's no work-around (i.e. some way to load the message chunks from the main entry on the server), then i think globalize-webpack-plugin needs to be updated to take the configuarion target into consideration and place the messages into the entry bundle when target = node, and in separate bundles when target = web.
The text was updated successfully, but these errors were encountered: