Improve webpack integration

- added gulp build --watch
- updated documentation
- bundle is now loaded after DOMContentLoaded event

Related to blueprint webpack

Change-Id: I04c341987002687efd6713c5296b23e491aacd6f
This commit is contained in:
Vitaly Kramskikh 2015-11-07 14:47:27 +07:00
parent 585e200d20
commit 36dac36184
3 changed files with 27 additions and 8 deletions

View File

@ -279,6 +279,17 @@ Running Nailgun in Fake Mode
gulp dev-server --dev-server-host=127.0.0.1 --dev-server-port=8080 --nailgun-host=127.0.0.1 --nailgun-port=8000
If you don't want to use a development server but would like to recompile
the bundle on any change, use::
gulp build --watch
If automatic rebuild on change doesn't work, most likely you need to
increase the limit of inotify watches::
echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches
Note: Diagnostic Snapshot is not available in a Fake mode.
Running the Fuel System Tests

View File

@ -249,10 +249,16 @@ gulp.task('build', function(cb) {
new webpack.optimize.UglifyJsPlugin({compress: {warnings: false}})
);
}
if (argv.watch) {
config.watch = true;
}
rimraf.sync(config.output.path);
webpack(config).run(function(err, stats) {
var compiler = webpack(config);
var run = config.watch ? compiler.watch.bind(compiler, config.watchOptions) : compiler.run.bind(compiler);
run(function(err, stats) {
if (err) return cb(err);
gutil.log(stats.toString(WEBPACK_STATS_OPTIONS));
@ -274,7 +280,7 @@ gulp.task('build', function(cb) {
.pipe(indexFilter.restore())
.pipe(gulp.dest(targetDir))
.on('end', cb);
} else {
} else if (!config.watch) {
cb();
}
});

View File

@ -60,12 +60,14 @@
}());
if (hasCookies && hasStorage) {
loadScript(
'static/build/bundle.js?__CACHE_BUST__',
'Failed to load compressed Fuel UI bundle. ' +
'If you are using development environment, ' +
'please run "gulp build" to compile Fuel UI.'
);
document.addEventListener('DOMContentLoaded', function() {
loadScript(
'static/build/bundle.js?__CACHE_BUST__',
'Failed to load compressed Fuel UI bundle. ' +
'If you are using development environment, ' +
'please run "gulp build" to compile Fuel UI.'
);
});
} else {
showError('Fuel UI requires Cookies and LocalStorage to work');
}