How to set React to production mode when using Gulp

后端 未结 5 1878
盖世英雄少女心
盖世英雄少女心 2021-02-03 20:36

I need to run React in production mode, which presumably entails defining the following somewhere in the enviornment:

process.env.NODE_ENV = \'production\';
         


        
5条回答
  •  Happy的楠姐
    2021-02-03 21:19

    Also you may use handy way with gulp-environments:

    var environments = require('gulp-environments');
    
    var production = environments.production;
    
    gulp.src(paths.js)
        .pipe(concat("app.js"))
        // only minify the compiled JS in production mode
        .pipe(production(uglify()))
        .pipe(gulp.dest("./public/app/js/"));
    

    To run gulp in production mode:

    gulp build --env=production
    

提交回复
热议问题