node.js - How can I set NODE_ENV? -


i using gulp in reactjs solution , want set node_env, tried this:

gulp.task('set-dev-node-env', function() {     return process.env.node_env = 'development'; }); //dev environment run gulp.task('default', ['set-dev-node-env', 'webpack-dev-server']); 

when run gulp , check chromeconsole says:

testing process.env.node_env undefined 

what missing or how can set node_env variable? set in gulpfile somehow.

here complete project: github

since using webpack can use webpack define plugin inject node_env

for example in webpack.config.dev.js:

module.exports = {   ...    plugins: [     ...     new webpack.defineplugin({       'process.env.node_env': json.stringify('development'),     }),   ], }; 

then in react code have access node_env set process.env.node_env.


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -