Reputation: 2135
I run this command:
browserify src.js -t [ babelify --presets [ react ] ] > build.js
and I get a single file that can be used by it's own. Works fine, but it's NODE_ENV is set to development and I get a console.log about downloading React DevTools.
How do I set it to production? I browsed around and didn't find anything that worked for me. I tried envify, but no luck (I'm very newb with JS builds).
I tried putting --NODE_ENV production somewhere in the line above, but I'm very new to browserify and babelify so I'm basically doing a trial and error.
Upvotes: 4
Views: 3830
Reputation: 2452
You set NODE_ENV
as production.
My production script usually looks something like this, nothing too spectacular
NODE_PATH=./src/components:./src NODE_ENV=production browserify ./src/app.js --extension .jsx -t babelify -t brfs | uglifyjs > ./dist/main.js
Note that this does not require envify
, although the documentation suggests that it should. You can test this simply by changing the NODE_ENV
to something else, anything else and React throws the devtools warning, but with production
set it does not even though envify
is not included in the transforms. There may be a better way of testing whether React is in production mode, or the documentation may not be up to date, this is tested with React 0.14.0.
edit React specifies its own browserify
config which adds the envify
transform, hence why it works. I have kept the above paragraph untouched as it is not immediately obvious why this all works, and this paragraph hopefully clears it up.
Upvotes: 5