From d42f36e79d23e6c6fd67fbb11945d21f647fbd2c Mon Sep 17 00:00:00 2001 From: Espen Hovlandsdal Date: Thu, 27 Jun 2019 13:52:41 +0200 Subject: [PATCH] [chore] Fix javascript not being rebuilt after first change --- gulpfile.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5bf6d67ed74..86702a67ebd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -75,8 +75,8 @@ if (path.win32 === path) { libFragment = '$1/lib/' } -const logCompile = (file, enc, cb) => { - gutil.log('Compiling', `'${chalk.cyan(file._path || file.path)}'...`) +const logCompile = from => (file, enc, cb) => { + gutil.log(`[${from}] Compiling`, `'${chalk.cyan(file._path || file.path)}'...`) cb(null, file) } @@ -91,6 +91,9 @@ const pkgPath = (cwd, sourcePath) => path.relative(path.join(cwd, 'packages'), s const getLogErrorHandler = () => plumber({errorHandler: err => gutil.log(err.stack)}) const getNoopErrorHandler = () => through.obj((chunk, enc, cb) => cb(null, chunk)) const buildTypeScript = getTypeScriptBuilder(getNoopErrorHandler) +const watchJavaScript = series(buildJavaScript, function watchJavascriptRebuild() { + watch(scripts, watchJavaScriptRebuild) +}) const watchTypeScript = series( getTypeScriptBuilder(getLogErrorHandler), function watchTypescriptRebuild() { @@ -115,7 +118,7 @@ function buildJavaScript() { hasChanged: compareModified }) ) - .pipe(through.obj(logCompile)) + .pipe(through.obj(logCompile('JS'))) .pipe(babel()) .pipe(assetFilter.restore) .pipe( @@ -128,7 +131,7 @@ function buildJavaScript() { .pipe(dest(packagesPath)) } -function watchJavaScript() { +function watchJavaScriptRebuild() { return src(scripts, srcOpts) .pipe(plumber({errorHandler: err => gutil.log(err.stack)})) .pipe( @@ -139,7 +142,7 @@ function watchJavaScript() { }) ) .pipe(newer(packagesPath)) - .pipe(through.obj(logCompile)) + .pipe(through.obj(logCompile('JS'))) .pipe(babel()) .pipe(dest(packagesPath)) } @@ -174,7 +177,7 @@ function getTypeScriptBuilder(getErrorHandler) { }) ) .pipe(getErrorHandler()) - .pipe(through.obj(logCompile)) + .pipe(through.obj(logCompile('TS'))) .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: './'})) .pipe(dest(project.options.outDir)) )