From f00c3226895e4b571c7e7ca702276c5c75fa789b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 28 Feb 2016 10:12:25 +0200 Subject: [PATCH] Add template compilation to the gulp pipeline. Just for avoid cache problems in production. --- gulpfile.js | 19 +++++++++++++++-- npm-shrinkwrap.json | 21 ++++++++++++++++--- package.json | 2 ++ .../{public/index.html => index.mustache} | 4 ++-- 4 files changed, 39 insertions(+), 7 deletions(-) rename resources/{public/index.html => index.mustache} (76%) diff --git a/gulpfile.js b/gulpfile.js index 421306a4d..1c9b46e50 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,6 +7,8 @@ var autoprefixer = require('gulp-autoprefixer'); var watch = require("gulp-watch"); var cssmin = require("gulp-cssmin"); var rimraf = require("rimraf"); +var mustache = require("gulp-mustache"); +var rename = require("gulp-rename"); var paths = {}; paths.app = "./resources/"; @@ -34,6 +36,19 @@ gulp.task("cssmin", function() { .pipe(gulp.dest(paths.output + "css/")); }); +gulp.task("template", function() { + var ts = Math.floor(new Date()); + var tmpl = mustache({ + jsfile: "/js/main.js?v=" + ts, + cssfile: "/css/main.css?v=" + ts + }) + + return gulp.src(paths.app + "index.mustache") + .pipe(tmpl) + .pipe(rename("index.html")) + .pipe(gulp.dest(paths.output)); +}); + gulp.task("styles-dev", function(next) { runseq("scss", "autoprefixer", next); }); @@ -61,10 +76,10 @@ gulp.task("copy", function() { // Default gulp.task("dist", function(next) { - runseq("styles-dist", "cssmin", "clean-dist", "copy", next); + runseq("styles-dist", "cssmin", "template", "clean-dist", "copy", next); }); // Watch -gulp.task("default", ["styles-dev"], function () { +gulp.task("default", ["styles-dev", "template"], function () { gulp.watch(paths.scss, ["styles-dev"]); }); diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 50fc0b20b..0dce9f694 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -752,6 +752,11 @@ "from": "graceful-fs@>=2.0.0 <2.1.0", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz" }, + "gulp-rename": { + "version": "1.1.0", + "from": "gulp-rename@>=1.1.0 <1.2.0", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz" + }, "gulp-util": { "version": "2.2.20", "from": "gulp-util@>=2.2.0 <2.3.0", @@ -824,15 +829,20 @@ } } }, + "gulp-mustache": { + "version": "2.2.0", + "from": "gulp-mustache@latest", + "resolved": "https://registry.npmjs.org/gulp-mustache/-/gulp-mustache-2.2.0.tgz" + }, "gulp-plumber": { "version": "1.1.0", "from": "gulp-plumber@1.1.0", "resolved": "https://registry.npmjs.org/gulp-plumber/-/gulp-plumber-1.1.0.tgz" }, "gulp-rename": { - "version": "1.1.0", - "from": "gulp-rename@>=1.1.0 <1.2.0", - "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz" + "version": "1.2.2", + "from": "gulp-rename@latest", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz" }, "gulp-sass": { "version": "2.2.0", @@ -1373,6 +1383,11 @@ "from": "multipipe@>=0.1.2 <0.2.0", "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz" }, + "mustache": { + "version": "2.2.1", + "from": "mustache@>=2.2.1 <3.0.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-2.2.1.tgz" + }, "nan": { "version": "2.2.0", "from": "nan@>=2.0.8 <3.0.0", diff --git a/package.json b/package.json index 0dc2bec0c..ee998bf01 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "gulp-autoprefixer": "3.1.0", "gulp-clean": "0.3.1", "gulp-cssmin": "0.1.7", + "gulp-mustache": "2.2.0", "gulp-plumber": "1.1.0", + "gulp-rename": "1.2.2", "gulp-sass": "2.2.0", "gulp-watch": "4.3.5", "rimraf": "2.5.2", diff --git a/resources/public/index.html b/resources/index.mustache similarity index 76% rename from resources/public/index.html rename to resources/index.mustache index e6211b5c2..d6254fed3 100644 --- a/resources/public/index.html +++ b/resources/index.mustache @@ -4,12 +4,12 @@ uxbox.io - ??? - +
- +