From bfef9b494098b9948fe5b0d2f757513d4289ec1b Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 16 Sep 2014 21:41:49 +1200 Subject: Slightly more verbose gulping, remove strict declarations for now. --- libmproxy/web/static/js/app.js | 3 -- web/gulpfile.js | 67 ++++++++++++++++++++++++++------------ web/src/js/stores/base.js | 1 - web/src/js/stores/eventlogstore.js | 1 - web/src/js/stores/settingstore.js | 1 - 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/libmproxy/web/static/js/app.js b/libmproxy/web/static/js/app.js index 047672e4..c095fd44 100644 --- a/libmproxy/web/static/js/app.js +++ b/libmproxy/web/static/js/app.js @@ -52,7 +52,6 @@ var SettingsActions = { } }; -"use strict"; function EventEmitter() { this.listeners = {}; @@ -79,7 +78,6 @@ EventEmitter.prototype.removeListener=function(event, f) { } }; -"use strict"; function _SettingsStore() { EventEmitter.call(this); @@ -110,7 +108,6 @@ _.extend(_SettingsStore.prototype, EventEmitter.prototype, { var SettingsStore = new _SettingsStore(); AppDispatcher.register(SettingsStore.handle.bind(SettingsStore)); -"use strict"; // // We have an EventLogView and an EventLogStore: // The basic architecture is that one can request views on the event log diff --git a/web/gulpfile.js b/web/gulpfile.js index 50c1a3fa..4130012f 100644 --- a/web/gulpfile.js +++ b/web/gulpfile.js @@ -53,67 +53,92 @@ var path = { fonts: ["src/vendor/fontawesome/fontawesome-webfont.*"], html: ["src/*.html", "!src/benchmark.html", "!src/test.html"] }; + + gulp.task("fonts", function () { return gulp.src(path.fonts) .pipe(gulp.dest(path.dist + "static/fonts")); }); -function styles(files, dev) { + +function styles_dev(files) { + return (gulp.src(files, {base: "src", cwd: "src"}) + .pipe(dont_break_on_errors()) + .pipe(sourcemaps.init()) + .pipe(less()) + .pipe(sourcemaps.write(".", {sourceRoot: "/static"})) + .pipe(gulp.dest(path.dist + "static")) + .pipe(livereload({ auto: false }))); +} +gulp.task("styles-app-dev", styles_dev.bind(undefined, path.css.app)); +gulp.task("styles-vendor-dev", styles_dev.bind(undefined, path.css.vendor)); +gulp.task("styles-dev", ["styles-app-dev", "styles-vendor-dev"]); + + +function styles_prod(files) { return (gulp.src(files, {base: "src", cwd: "src"}) - .pipe(dev ? dont_break_on_errors() : gutil.noop()) - .pipe(dev ? sourcemaps.init() : gutil.noop()) .pipe(less()) - .pipe(dev ? sourcemaps.write(".", {sourceRoot: "/static"}) : gutil.noop()) // No sourcemaps support yet :-/ // https://github.com/jonathanepollack/gulp-minify-css/issues/34 - .pipe(!dev ? minifyCSS() : gutil.noop()) + .pipe(minifyCSS()) .pipe(gulp.dest(path.dist + "static")) .pipe(livereload({ auto: false }))); } -gulp.task("styles-app-dev", styles.bind(undefined, path.css.app, true)); -gulp.task("styles-app-prod", styles.bind(undefined, path.css.app, false)); -gulp.task("styles-vendor-dev", styles.bind(undefined, path.css.vendor, true)); -gulp.task("styles-vendor-prod", styles.bind(undefined, path.css.vendor, false)); -gulp.task("styles-dev", ["styles-app-dev", "styles-vendor-dev"]); +gulp.task("styles-app-prod", styles_prod.bind(undefined, path.css.app)); +gulp.task("styles-vendor-prod", styles_prod.bind(undefined, path.css.vendor)); gulp.task("styles-prod", ["styles-app-prod", "styles-vendor-prod"]); -function scripts(files, filename, dev) { + +function scripts_dev(files, filename) { return gulp.src(files, {base: "src", cwd: "src"}) - .pipe(dev ? dont_break_on_errors(): gutil.noop()) - .pipe(dev ? sourcemaps.init() : gutil.noop()) - .pipe(react({harmony: false})) + .pipe(dont_break_on_errors()) + .pipe(sourcemaps.init()) + .pipe(react()) .pipe(concat(filename)) - .pipe(!dev ? uglify() : gutil.noop()) - .pipe(dev ? sourcemaps.write(".", {sourceRoot: "/static"}) : gutil.noop()) + .pipe(sourcemaps.write(".", {sourceRoot: "/static"})) .pipe(gulp.dest(path.dist + "static/js")) .pipe(livereload({ auto: false })); } -gulp.task("scripts-app-dev", scripts.bind(undefined, path.js.app, "app.js", true)); -gulp.task("scripts-app-prod", scripts.bind(undefined, path.js.app, "app.js", false)); -gulp.task("scripts-vendor-dev", scripts.bind(undefined, path.js.vendor, "vendor.js", true)); -gulp.task("scripts-vendor-prod", scripts.bind(undefined, path.js.vendor, "vendor.js", false)); +gulp.task("scripts-app-dev", scripts_dev.bind(undefined, path.js.app, "app.js")); +gulp.task("scripts-vendor-dev", scripts_dev.bind(undefined, path.js.vendor, "vendor.js")); gulp.task("scripts-dev", ["scripts-app-dev", "scripts-vendor-dev"]); + + +function scripts_prod(files, filename) { + return gulp.src(files, {base: "src", cwd: "src"}) + .pipe(react()) + .pipe(concat(filename)) + .pipe(uglify()) + .pipe(gulp.dest(path.dist + "static/js")) + .pipe(livereload({ auto: false })); +} +gulp.task("scripts-app-prod", scripts_prod.bind(undefined, path.js.app, "app.js")); +gulp.task("scripts-vendor-prod", scripts_prod.bind(undefined, path.js.vendor, "vendor.js")); gulp.task("scripts-prod", ["scripts-app-prod", "scripts-vendor-prod"]); + gulp.task("jshint", function () { return gulp.src(["src/js/**"]) .pipe(dont_break_on_errors()) - .pipe(react({harmony: false /* Do not do Harmony transformation for JSHint */})) + .pipe(react()) .pipe(jshint()) .pipe(jshint.reporter("jshint-stylish")) }); + gulp.task("html", function () { return gulp.src(path.html) .pipe(gulp.dest(path.dist + "templates")) .pipe(livereload({ auto: false })); }); + gulp.task('test', function() { return gulp.src('src/test.html') .pipe(qunit({verbose: true})); }); + common = ["fonts", "html", "jshint"]; gulp.task("dev", common.concat(["styles-dev", "scripts-dev"])); gulp.task("prod", common.concat(["styles-prod", "scripts-prod"])); diff --git a/web/src/js/stores/base.js b/web/src/js/stores/base.js index c02c77b6..e72141b5 100644 --- a/web/src/js/stores/base.js +++ b/web/src/js/stores/base.js @@ -1,4 +1,3 @@ -"use strict"; function EventEmitter() { this.listeners = {}; diff --git a/web/src/js/stores/eventlogstore.js b/web/src/js/stores/eventlogstore.js index dbecc749..23f8d3ed 100644 --- a/web/src/js/stores/eventlogstore.js +++ b/web/src/js/stores/eventlogstore.js @@ -1,4 +1,3 @@ -"use strict"; // // We have an EventLogView and an EventLogStore: // The basic architecture is that one can request views on the event log diff --git a/web/src/js/stores/settingstore.js b/web/src/js/stores/settingstore.js index 9139076e..23ac6dca 100644 --- a/web/src/js/stores/settingstore.js +++ b/web/src/js/stores/settingstore.js @@ -1,4 +1,3 @@ -"use strict"; function _SettingsStore() { EventEmitter.call(this); -- cgit v1.2.3