peter-mouland / react-lego

React-lego : incrementally add more cool stuff to your react app
http://react-lego.herokuapp.com/
MIT License
414 stars 36 forks source link

Compilation fails for svg branch #32

Closed ngoctranfire closed 8 years ago

ngoctranfire commented 8 years ago

Hey, I think this is an isomorphic webpack issue. I noticed that npm start( which does the compilation for the server build) fails for the svg branch. Not exactly sure the issue and was wondering if you can look into that.

ngoctranfire commented 8 years ago

I actually figured this out. I feel that, in this branch, with isomorphic tools setup, we shouldn't be using the npm start command that we are using. Instead, we should be running the src/server-entry.js directly, after compiling our webpack production build. This means that we don't actually need to compile webpack.config.server.js. It's not longer needed since we have webpack isomorphic tools. Should I make a pull request for this?

peter-mouland commented 8 years ago

I used the compilation to remove the need to babel-core/register in prod. It would be nice to use babel cli (i.e. babel src -d compiled or whatever) rather than webpack, but the server should still start from compiled directory rather than src (babel runs in memory and in prod this takes up alot of memory!)

ngoctranfire commented 8 years ago

Hmmm.. I see what you mean... Yea I was actually using babel-register to allow this to happen. But... Have you tried using the babel src -d compiled and then running it from there? Does it work?

peter-mouland commented 8 years ago

the problem we then run into is importing scss and svg on the server. for some reason node-hook gets ignored once the files have been put through babel.

This is a problem i'd love to solve though, i'd much prefer to use babel over webpack as the compiler

peter-mouland commented 8 years ago

i'm getting to the bottom of this : https://github.com/halt-hammerzeit/webpack-isomorphic-tools/issues/113#issuecomment-255533679

looks like i have to tweak my server code

ngoctranfire commented 8 years ago

Interesting. Great that he walked you through the problem as well!

peter-mouland commented 8 years ago

this commit has fixed the bug https://github.com/peter-mouland/react-lego/commit/bfbb4c9dda285a70bbc606977fd855328bed1b23

peter-mouland commented 8 years ago

it's been a glorious day. with this commit i've also been able to get rid of the need of using webpack on the server! https://github.com/peter-mouland/react-lego/commit/4b395353c7897ffcfaf3b96372aaa4264859c514