Minify react in production
parent
8aace767c0
commit
c71636b629
|
@ -13,6 +13,8 @@ var Rx = require('rx'),
|
|||
reduce = require('gulp-reduce-file'),
|
||||
sortKeys = require('sort-keys'),
|
||||
debug = require('debug')('freecc:gulp'),
|
||||
yargs = require('yargs'),
|
||||
uglify = require('gulp-uglify'),
|
||||
|
||||
// react app
|
||||
webpack = require('gulp-webpack'),
|
||||
|
@ -38,7 +40,7 @@ var Rx = require('rx'),
|
|||
|
||||
Rx.config.longStackSupport = true;
|
||||
|
||||
var __DEV__ = process.env.NODE_ENV !== 'production';
|
||||
var __DEV__ = !yargs.argv.p;
|
||||
var reloadDelay = 1000;
|
||||
var reload = sync.reload;
|
||||
var paths = {
|
||||
|
@ -198,6 +200,8 @@ gulp.task('lint-json', function() {
|
|||
gulp.task('test-challenges', ['lint-json']);
|
||||
|
||||
gulp.task('pack-client', function() {
|
||||
if (!__DEV__) { console.log('\n\nbundling production\n\n'); }
|
||||
|
||||
var manifestName = 'react-manifest.json';
|
||||
var dest = webpackConfig.output.path;
|
||||
|
||||
|
@ -208,6 +212,7 @@ gulp.task('pack-client', function() {
|
|||
webpackConfig,
|
||||
webpackOptions
|
||||
)))
|
||||
.pipe(__DEV__ ? gutil.noop() : uglify())
|
||||
.pipe(gulp.dest(dest))
|
||||
.pipe(rev())
|
||||
// copy files to public
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"scripts": {
|
||||
"first-time": "npm run create-rev && echo '\n\nseeding database\n\n' && node seed && node seed/nonprofits",
|
||||
"create-rev": "test ! -e server/rev-manifest.json && echo '\n\ncreating manifest\n\n' && touch server/rev-manifest.json && echo '{}' >> server/rev-manifest.json",
|
||||
"build": "gulp build",
|
||||
"build": "NODE_ENV=production gulp build -p",
|
||||
"start": "babel-node server/server.js",
|
||||
"prestart-production": "bower cache clean && bower install && gulp build",
|
||||
"start-production": "node pm2Start",
|
||||
|
@ -68,6 +68,7 @@
|
|||
"gulp-reduce-file": "0.0.1",
|
||||
"gulp-rev": "^6.0.1",
|
||||
"gulp-rev-replace": "~0.4.2",
|
||||
"gulp-uglify": "^1.5.1",
|
||||
"gulp-util": "^3.0.6",
|
||||
"gulp-webpack": "^1.5.0",
|
||||
"helmet": "~0.14.0",
|
||||
|
@ -117,7 +118,8 @@
|
|||
"url-regex": "^3.0.0",
|
||||
"validator": "^4.2.1",
|
||||
"webpack": "^1.9.12",
|
||||
"xss-filters": "^1.2.6"
|
||||
"xss-filters": "^1.2.6",
|
||||
"yargs": "^3.30.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"blessed": "~0.1.81",
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
|
||||
var __DEV__ = process.env.NODE_ENV !== 'production';
|
||||
|
||||
module.exports = {
|
||||
entry: './client',
|
||||
|
@ -27,5 +30,12 @@ module.exports = {
|
|||
}
|
||||
]
|
||||
},
|
||||
plugins: []
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
'NODE_ENV': JSON.stringify(__DEV__ ? 'development' : 'production')
|
||||
},
|
||||
'__DEVTOOLS__': !__DEV__
|
||||
})
|
||||
]
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue