chore(build): make watch faster / only build what is needed
This commit is contained in:
parent
88aac42c6d
commit
e5224d2cb3
61
gulpfile.js
61
gulpfile.js
@ -11,7 +11,8 @@ var ejs = require('gulp-ejs');
|
|||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
// import js2dart and traceur build tasks
|
// import js2dart and traceur build tasks
|
||||||
require('./tools/js2dart/gulpfile').install(gulp);
|
var js2dartTasks = require('./tools/js2dart/gulp-tasks');
|
||||||
|
js2dartTasks.install(gulp);
|
||||||
|
|
||||||
var traceurJsOptions = {
|
var traceurJsOptions = {
|
||||||
annotations: true, // parse annotations
|
annotations: true, // parse annotations
|
||||||
@ -20,8 +21,7 @@ var traceurJsOptions = {
|
|||||||
modules: 'register',
|
modules: 'register',
|
||||||
typeAssertionModule: 'assert',
|
typeAssertionModule: 'assert',
|
||||||
typeAssertions: true,
|
typeAssertions: true,
|
||||||
moduleName: true,
|
moduleName: true
|
||||||
reload: true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var traceur = require('./tools/js2dart/gulp-traceur');
|
var traceur = require('./tools/js2dart/gulp-traceur');
|
||||||
@ -58,24 +58,18 @@ gulp.task('modules/clean', function() {
|
|||||||
.pipe(clean());
|
.pipe(clean());
|
||||||
});
|
});
|
||||||
|
|
||||||
function removeSrc(path) {
|
|
||||||
//path.dirname = path.dirname.replace('/src', '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function createModuleTask(sourceTypeConfig, isWatch) {
|
function createModuleTask(sourceTypeConfig, isWatch) {
|
||||||
var start = isWatch ? watch : gulp.src.bind(gulp);
|
var start = isWatch ? watch : gulp.src.bind(gulp);
|
||||||
return function(done) {
|
return function(done) {
|
||||||
var transpile = start(sourceTypeConfig.transpileSrc)
|
var transpile = start(sourceTypeConfig.transpileSrc)
|
||||||
.pipe(rename({extname: '.'+sourceTypeConfig.outputExt}))
|
.pipe(rename({extname: '.'+sourceTypeConfig.outputExt}))
|
||||||
.pipe(rename(removeSrc))
|
|
||||||
.pipe(sourceTypeConfig.compiler())
|
.pipe(sourceTypeConfig.compiler())
|
||||||
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
||||||
var copy = start(sourceTypeConfig.copySrc)
|
var copy = start(sourceTypeConfig.copySrc)
|
||||||
.pipe(rename(removeSrc))
|
|
||||||
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
.pipe(gulp.dest(sourceTypeConfig.outputDir));
|
||||||
// TODO: provide the list of files to the template
|
// TODO: provide the list of files to the template
|
||||||
|
// automatically!
|
||||||
var html = start(sourceTypeConfig.htmlSrc)
|
var html = start(sourceTypeConfig.htmlSrc)
|
||||||
.pipe(rename(removeSrc))
|
|
||||||
.pipe(ejs({
|
.pipe(ejs({
|
||||||
type: sourceTypeConfig.outputExt
|
type: sourceTypeConfig.outputExt
|
||||||
}))
|
}))
|
||||||
@ -86,9 +80,7 @@ function createModuleTask(sourceTypeConfig, isWatch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('modules/build.dart', createModuleTask(sourceTypeConfigs.dart, false));
|
gulp.task('modules/build.dart', createModuleTask(sourceTypeConfigs.dart, false));
|
||||||
gulp.task('modules/watch.dart', createModuleTask(sourceTypeConfigs.dart, true));
|
|
||||||
gulp.task('modules/build.js', createModuleTask(sourceTypeConfigs.js, false));
|
gulp.task('modules/build.js', createModuleTask(sourceTypeConfigs.js, false));
|
||||||
gulp.task('modules/watch.js', createModuleTask(sourceTypeConfigs.js, true));
|
|
||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
// WEB SERVER
|
// WEB SERVER
|
||||||
@ -111,27 +103,36 @@ gulp.task('serve', connect.server({
|
|||||||
// general targets
|
// general targets
|
||||||
|
|
||||||
gulp.task('clean', function(done) {
|
gulp.task('clean', function(done) {
|
||||||
return runSequence(['traceur/clean', 'modules/clean'], done);
|
return runSequence(['traceur/clean', 'js2dart/clean', 'modules/clean'], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build', function(done) {
|
gulp.task('build', function() {
|
||||||
// By using runSequence here we are decoupling the cleaning from the rest of the build tasks
|
return runSequence(
|
||||||
// Otherwise, we have to add clean as a dependency on every task to ensure that it completes
|
// sequential
|
||||||
// before they begin.
|
'traceur/build', 'js2dart/build',
|
||||||
|
// parallel
|
||||||
|
['modules/build.dart', 'modules/build.js']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('watch', function() {
|
||||||
|
var traceurWatch = watch(js2dartTasks.paths.traceurSrc, function(_, done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
'js2dart/build',
|
// sequential
|
||||||
|
'traceur/build', 'js2dart/build', 'js2dart/test',
|
||||||
|
// parallel
|
||||||
['modules/build.dart', 'modules/build.js'],
|
['modules/build.dart', 'modules/build.js'],
|
||||||
done
|
done);
|
||||||
);
|
});
|
||||||
});
|
var js2dartWatch = watch(js2dartTasks.paths.js2dartSrc, function(_, done) {
|
||||||
|
|
||||||
gulp.task('watch', function(done) {
|
|
||||||
// By using runSequence here we are decoupling the cleaning from the rest of the build tasks
|
|
||||||
// Otherwise, we have to add clean as a dependency on every task to ensure that it completes
|
|
||||||
// before they begin.
|
|
||||||
runSequence(
|
runSequence(
|
||||||
'build',
|
// sequential
|
||||||
['js2dart/watch', 'modules/watch.dart', 'modules/watch.js'],
|
'js2dart/build', 'js2dart/test',
|
||||||
done
|
// parallel
|
||||||
);
|
['modules/build.dart', 'modules/build.js'],
|
||||||
|
done);
|
||||||
|
});
|
||||||
|
var dartModuleWatch = createModuleTask(sourceTypeConfigs.dart, true)();
|
||||||
|
var jsModuleWatch = createModuleTask(sourceTypeConfigs.js, true)();
|
||||||
|
return mergeStreams(traceurWatch, js2dartWatch, dartModuleWatch, jsModuleWatch);
|
||||||
});
|
});
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 98702b95e2e75254d1223cc4ac617142efe25487
|
Subproject commit 3f5e00b6be9ba8c2920732a08e2eb113f1485631
|
Loading…
x
Reference in New Issue
Block a user