fix manifest generation during webpack watch
fix gulp debug statements during gulp should always be on
This commit is contained in:
61
gulpfile.js
61
gulpfile.js
@ -1,3 +1,6 @@
|
|||||||
|
// enable debug for gulp
|
||||||
|
process.env.DEBUG = process.env.DEBUG || 'freecc:*';
|
||||||
|
|
||||||
require('babel-core/register');
|
require('babel-core/register');
|
||||||
var Rx = require('rx'),
|
var Rx = require('rx'),
|
||||||
gulp = require('gulp'),
|
gulp = require('gulp'),
|
||||||
@ -6,6 +9,7 @@ var Rx = require('rx'),
|
|||||||
// utils
|
// utils
|
||||||
plumber = require('gulp-plumber'),
|
plumber = require('gulp-plumber'),
|
||||||
notify = require('gulp-notify'),
|
notify = require('gulp-notify'),
|
||||||
|
gutil = require('gulp-util'),
|
||||||
reduce = require('gulp-reduce-file'),
|
reduce = require('gulp-reduce-file'),
|
||||||
sortKeys = require('sort-keys'),
|
sortKeys = require('sort-keys'),
|
||||||
debug = require('debug')('freecc:gulp'),
|
debug = require('debug')('freecc:gulp'),
|
||||||
@ -43,6 +47,7 @@ var paths = {
|
|||||||
'!public/js/bundle*',
|
'!public/js/bundle*',
|
||||||
'node_modules/',
|
'node_modules/',
|
||||||
'client/',
|
'client/',
|
||||||
|
'server/manifests/*.json',
|
||||||
'server/rev-manifest.json'
|
'server/rev-manifest.json'
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -143,7 +148,7 @@ var syncDepenedents = [
|
|||||||
'js',
|
'js',
|
||||||
'less',
|
'less',
|
||||||
'dependents',
|
'dependents',
|
||||||
'pack-client',
|
'pack-watch',
|
||||||
'build-manifest'
|
'build-manifest'
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -189,16 +194,48 @@ gulp.task('pack-client', function() {
|
|||||||
.pipe(gulp.dest(paths.manifest));
|
.pipe(gulp.dest(paths.manifest));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('pack-watch', function() {
|
var defaultStatsOptions = {
|
||||||
return gulp.src(webpackConfig.entry)
|
colors: gutil.colors.supportsColor,
|
||||||
|
hash: false,
|
||||||
|
timings: false,
|
||||||
|
chunks: false,
|
||||||
|
chunkModules: false,
|
||||||
|
modules: false,
|
||||||
|
children: true,
|
||||||
|
version: true,
|
||||||
|
cached: false,
|
||||||
|
cachedAssets: false,
|
||||||
|
reasons: false,
|
||||||
|
source: false,
|
||||||
|
errorDetails: false
|
||||||
|
};
|
||||||
|
|
||||||
|
gulp.task('pack-watch', function(cb) {
|
||||||
|
var called = false;
|
||||||
|
gulp.src(webpackConfig.entry)
|
||||||
.pipe(plumber({ errorHandler: errorHandler }))
|
.pipe(plumber({ errorHandler: errorHandler }))
|
||||||
.pipe(webpack(Object.assign(
|
.pipe(webpack(Object.assign(
|
||||||
{},
|
{},
|
||||||
webpackConfig,
|
webpackConfig,
|
||||||
webpackOptions,
|
webpackOptions,
|
||||||
{ watch: true }
|
{ watch: true }
|
||||||
)))
|
), null, function(notUsed, stats) {
|
||||||
.pipe(gulp.dest(webpackConfig.output.path))
|
if (stats) {
|
||||||
|
gutil.log(stats.toString(defaultStatsOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!called) {
|
||||||
|
debug('webpack watch completed');
|
||||||
|
called = true;
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(webpackConfig.output.path));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('pack-watch-manifest', ['pack-watch'], function() {
|
||||||
|
return gulp.src(webpackConfig.output.path + '/bundle.js')
|
||||||
.pipe(rev())
|
.pipe(rev())
|
||||||
// copy files to public
|
// copy files to public
|
||||||
.pipe(gulp.dest(webpackConfig.output.path))
|
.pipe(gulp.dest(webpackConfig.output.path))
|
||||||
@ -301,7 +338,9 @@ var watchDependents = [
|
|||||||
'dependents',
|
'dependents',
|
||||||
'serve',
|
'serve',
|
||||||
'sync',
|
'sync',
|
||||||
'build-manifest'
|
'build-manifest',
|
||||||
|
'pack-watch',
|
||||||
|
'pack-watch-manifest'
|
||||||
];
|
];
|
||||||
|
|
||||||
gulp.task('watch', watchDependents, function() {
|
gulp.task('watch', watchDependents, function() {
|
||||||
@ -311,7 +350,15 @@ gulp.task('watch', watchDependents, function() {
|
|||||||
gulp.watch(paths.js, ['js', 'dependents']);
|
gulp.watch(paths.js, ['js', 'dependents']);
|
||||||
gulp.watch(paths.dependents, ['dependents']);
|
gulp.watch(paths.dependents, ['dependents']);
|
||||||
gulp.watch(paths.manifest + '/*.json', ['build-manifest-watch']);
|
gulp.watch(paths.manifest + '/*.json', ['build-manifest-watch']);
|
||||||
|
gulp.watch(webpackConfig.output.path + '/bundle.js', ['pack-watch-manifest']);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', ['less', 'serve', 'sync', 'watch', 'pack-watch']);
|
gulp.task('default', [
|
||||||
|
'less',
|
||||||
|
'serve',
|
||||||
|
'pack-watch',
|
||||||
|
'pack-watch-manifest',
|
||||||
|
'watch',
|
||||||
|
'sync'
|
||||||
|
]);
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
"gulp-reduce-file": "0.0.1",
|
"gulp-reduce-file": "0.0.1",
|
||||||
"gulp-rev": "^6.0.1",
|
"gulp-rev": "^6.0.1",
|
||||||
"gulp-rev-replace": "^0.4.2",
|
"gulp-rev-replace": "^0.4.2",
|
||||||
|
"gulp-util": "^3.0.6",
|
||||||
"gulp-webpack": "^1.5.0",
|
"gulp-webpack": "^1.5.0",
|
||||||
"helmet": "~0.9.0",
|
"helmet": "~0.9.0",
|
||||||
"helmet-csp": "^0.2.3",
|
"helmet-csp": "^0.2.3",
|
||||||
|
Reference in New Issue
Block a user