Skip to content

Commit

Permalink
Only process changed client-side files and don't clean folder unless …
Browse files Browse the repository at this point in the history
…explicitly told to
  • Loading branch information
aydenp committed Sep 3, 2017
1 parent 11c9dff commit 0add18d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"fs-extra-promise": "^1.0.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-changed": "^3.1.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-uglify": "^2.1.2",
"helmet": "^3.8.1",
Expand Down
12 changes: 10 additions & 2 deletions util/JavaScriptProcessor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const fs = require("fs");
const path = require("path");
const gulp = require("gulp");
const uglify = require("gulp-uglify");
const babel = require("gulp-babel");
const sourcemaps = require('gulp-sourcemaps');
const changed = require('gulp-changed');
const del = require("del");

class JavaScriptProcessor {
Expand All @@ -23,9 +26,10 @@ class JavaScriptProcessor {
// Clean existing built JavaScript
gulp.task("clean", () => del([this.paths.scripts.built]));
// Process JavaScript
gulp.task("scripts", ["clean"], (cb) => {
gulp.task("scripts", (cb) => {
this.app.logger.info('Babel', "Processing JavaScript…");
var t = gulp.src(this.paths.scripts.src);
t = t.pipe(changed(this.paths.scripts.built))
t = t.pipe(sourcemaps.init());
t = t.pipe(babel({ presets: ["es2015"] }));
t = t.on("error", swallowError);
Expand All @@ -41,7 +45,11 @@ class JavaScriptProcessor {
}

processJavaScript() {
gulp.start(["watch", "scripts"]);
gulp.start(["scripts"]);
}

cleanJavaScript() {
gulp.start(["clean"]);
}

watchJavaScript() {
Expand Down

0 comments on commit 0add18d

Please sign in to comment.