Shopify / sprockets-commoner

Use Babel in Sprockets to compile JavaScript modules for the browser
MIT License
182 stars 22 forks source link

React warning in production #51

Open eltiare opened 7 years ago

eltiare commented 7 years ago

I get this error message when running my app in production mode:

application-c40ae74….js:2 Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.

The link suggests setting the environment variable NODE_ENV=production for some other preprocessors, but that doesn't seem to work with sprockets-commoner.

bouk commented 7 years ago

Environment variables are supposed to work: https://github.com/Shopify/sprockets-commoner/blob/master/test/env_test.rb

jtomaszewski commented 7 years ago

How do you make the env variables work?

I run the server with env NODE_ENV=development rails s and my js file has:

console.log('process.env', process.env);

but it throws Uncaught ReferenceError: process is not defined error. Should I do something more to make this env variable available?

bouk commented 7 years ago

It won't work if you do process.env, but process.env.NODE_ENV should get replaced with the correct environment variable.