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

webpacking the server for production #48

Closed
dustinsanders opened this issue Feb 20, 2016 · 10 comments
Closed

webpacking the server for production #48

dustinsanders opened this issue Feb 20, 2016 · 10 comments
Milestone

Comments

@dustinsanders
Copy link

Is there any interest in using webpack on the server for production, as outlined here. If there is interest, I can submit a pull request.

@dustinsanders dustinsanders changed the title webpacking the server for productino webpacking the server for production Feb 20, 2016
@YarivGilad
Copy link

+1 for compiling the server...
At the moment, production build is using Babel-register hook which was not meant to be used in production...
@dustinsanders - the link you mentioned is broken

@prank7
Copy link
Contributor

prank7 commented Apr 18, 2016

@dustinsanders sure it is. If you can submit a PR that would be great.

@prank7
Copy link
Contributor

prank7 commented Apr 18, 2016

@Ajar-Ajar here is the right link.

@prank7
Copy link
Contributor

prank7 commented Apr 18, 2016

IMHO we should have a different webpack config file for server-side, which builds a '/build/server.build.js'. Is there a better way to do this?

@YarivGilad
Copy link

@dustinsanders - thank you for the link, nice trick with the if-env script in the package.json to create a unified npm start rutine... the only thing I'm missing in this setup is that the server doesn't use es6 features like import that require a babel compilation. and suppose we do need to compile it, we will probably need to modify the folder structure to use both client and server under the dist folder...
@prank7 is webpack being used to compile the server as well? all the examples I came across so far had to do with the client only... have you tried it to compile the server before? interesting...

@prank7
Copy link
Contributor

prank7 commented Apr 19, 2016

@Ajar-Ajar I haven't done it before but that is what this link is suggesting.

@somus somus added this to the 2.0.0 milestone May 25, 2016
@somus somus mentioned this issue May 25, 2016
12 tasks
@somus somus closed this as completed May 30, 2016
@somus somus reopened this May 31, 2016
@somus
Copy link
Contributor

somus commented May 31, 2016

If we are webpacking the server, css-modules-require-hook is not working. We have to figure out another way to inject css modules class names in the rendered html. After that, we can keep enable server webpacking again.

@carloscuatin
Copy link
Contributor

👍

@lubien
Copy link

lubien commented Jun 1, 2016

This react-router tutorial use this approach to get externals:

  // keep node_module paths out of the bundle
  externals: fs.readdirSync(path.resolve(__dirname, 'node_modules')).concat([
    'react-dom/server', 'react/addons',
  ]).reduce(function (ext, mod) {
    ext[mod] = 'commonjs ' + mod
    return ext
  }, {}),

I've used it and got lots of problems (mostly with babel-polyfill). The solution was simply using Morhaus/webpack-externals-plugin.

I just wanted to share with you my experience. Hope this plugin could be helpful to v2.

My webpack config for server.

@somus
Copy link
Contributor

somus commented Jun 6, 2016

Done in e7975db.

@lubien Thanks for the suggestion. Added in 9aaf5a2.

@somus somus closed this as completed Jun 6, 2016
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

6 participants