bananaoomarang / isomorphic-redux

Isomorphic Redux demo, with routing and async actions
https://medium.com/@bananaoomarang/handcrafting-an-isomorphic-redux-application-with-love-40ada4468af4
MIT License
455 stars 87 forks source link

All dev dependencies are required for production #29

Closed mattgibson closed 8 years ago

mattgibson commented 8 years ago

Wipe out the node_modules folder with rm -rf node_modules, reinstall with npm install --production and then try npm start.

Errors appear about missing babel and other dev modules because of this line in server.jsx:

import webpackDev from './webpack.dev';

The conditional below is used to actuall run the imported function, but the files are all included anyway, leading to a very heavy slug on Heroku.

if (process.env.NODE_ENV == 'production') {
  app.use(express.static(path.join(__dirname, 'dist')));
} else {
  webpackDev(app);
} 
Dattaya commented 8 years ago

This is a very simple app. Similar to redux real world example everything's on one express server. You probably want to create another development express server like the one erikras/react-redux-universal-hot-example uses, or maybe require webpack.dev conditionally? (please, let me know of the result)

if (process.env.NODE_ENV !== 'production') {
  require('./webpack.dev')(app);
}

app.use(express.static(path.join(__dirname, 'dist')));
Dattaya commented 8 years ago

Tried it myself and it worked but I had to move babel to the production section (because of this line in index.js: require('babel/register')({});). But to run npm run build you have to install the dev dependencies anyway. p.s. I'll send a fix today-tomorrow

Dattaya commented 8 years ago

Hopefully #30 resolves this issue.

mattgibson commented 8 years ago

Fixed it using require('./webpack.dev'); as above. You do need to have all the deps for build, but they don't need to be sent to the browser, so I think the fix helps. Thanks for investigating so fast :)