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

[master/webpack2-*] 'npm start` use development build #13

Closed dlebedynskyi closed 7 years ago

dlebedynskyi commented 7 years ago

issue come from master branch but very visible in webpack2-hrm branch

Steps to reproduce

  1. set your NODE_ENV to development
  2. run npm run start:dev
  3. kill it and run npm run build:server and npm run start .
  4. Notice env still set to development. _build does sets NODEENV to production but it does so after build:server in prestart
  5. open localhost:3000 with network - watch /__webpack_hrm request.

Expected Manage node_env more consistent.

Suggestion

  "prestart": "rm -rf compiled && npm run build:server && npm run build",
  "prestart:dev": "NODE_ENV=development npm run build:dev",
    "build": "NODE_ENV=production webpack --config src/config/webpack.config.prod.js --optimize-minimize",
    "build:dev": "NODE_ENV=development webpack --config src/config/webpack.config.dev.js",
    "build:server": "NODE_ENV=production webpack --config src/config/webpack.config.server.js",
peter-mouland commented 7 years ago

interesting bug, thanks for pointing it out.

since, according the the environment.js, setting NODE_ENV to 'development' is default, I assume, setting the only build and build:server scripts to include prod would be enough.

Would you agree or would that still cause inconsistencies for your use case?

dlebedynskyi commented 7 years ago

enviroment.js will set to default if not env var is not set in process. but if it is set - like after build it stays production, correct?

peter-mouland commented 7 years ago

thanks for pointing out the problems - i've updated the code to include the node_env=production. I've decided to leave off the env for dev to allow a bit more flexibility. hopefully this will be ok - if it proves to still be problematic in the future i'll have to rethink it!