node.js - Accessing NODE_ENV environment variable in React on Rails -


i've got react on rails application hits api. want configure api endpoint localhost development , deployed app's url production.

client/package.json

 "scripts": {     "build:production": "node_env=production webpack --config webpack.config.js",  }, 

client/webpack.config.js

const devbuild = process.env.node_env !== 'production';  const config = {   entry: [     'es5-shim/es5-shim',     'es5-shim/es5-sham',     'babel-polyfill',     './app/bundles/main/startup/registration',   ],   output: {     filename: 'webpack-bundle.js',     path: __dirname + '/../app/assets/webpack',   },   resolve: {     extensions: ['.js', '.jsx'],   },   plugins: [     new webpack.environmentplugin({ node_env: 'development' }),   ] } 

i see process.env.node_env available in config/webpack.config.js (used here add source map devtools module exports), i'd way see environment in react code somewhere in client/. options if any?

i used process.env.node_env in redux action file successfully. i'm exporting node_env in webpack plugin definition shown below in webpack.config.js:

plugins: [     ...     new webpack.defineplugin({         'process.env': {             node_env: json.stringify('env_value')         }     }) ] 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -