2015-06-18 12:35:50 -05:00
|
|
|
var gulp = require("gulp");
|
2016-02-21 09:42:35 -05:00
|
|
|
var runseq = require('run-sequence');
|
2015-06-18 12:35:50 -05:00
|
|
|
var scss = require("gulp-sass");
|
|
|
|
var plumber = require("gulp-plumber");
|
|
|
|
var autoprefixer = require('gulp-autoprefixer');
|
|
|
|
var watch = require("gulp-watch");
|
2016-02-21 09:42:35 -05:00
|
|
|
var cssmin = require("gulp-cssmin");
|
2016-02-21 11:01:27 -05:00
|
|
|
var rimraf = require("rimraf");
|
2016-02-28 03:12:25 -05:00
|
|
|
var mustache = require("gulp-mustache");
|
|
|
|
var rename = require("gulp-rename");
|
2015-06-18 12:35:50 -05:00
|
|
|
|
|
|
|
var paths = {};
|
2016-02-21 09:42:35 -05:00
|
|
|
paths.app = "./resources/";
|
|
|
|
paths.output = "./resources/public/";
|
2016-02-21 13:42:01 -05:00
|
|
|
paths.dist = "./dist/";
|
2016-02-21 13:50:26 -05:00
|
|
|
paths.target = "./target/";
|
2015-06-18 12:35:50 -05:00
|
|
|
paths.scss = paths.app + "styles/**/*.scss";
|
|
|
|
|
2016-04-03 05:19:11 -05:00
|
|
|
function makeAutoprefixer() {
|
|
|
|
return autoprefixer('last 2 version',
|
|
|
|
'safari 5',
|
|
|
|
'ios 6',
|
|
|
|
'android 4');
|
|
|
|
}
|
|
|
|
|
|
|
|
function scssPipeline(options) {
|
|
|
|
var input = options.input;
|
|
|
|
var output = options.output;
|
|
|
|
|
|
|
|
return gulp.src(input)
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(scss({style: "expanded"}))
|
|
|
|
.pipe(makeAutoprefixer())
|
|
|
|
.pipe(gulp.dest(output));
|
|
|
|
}
|
2016-02-21 09:42:35 -05:00
|
|
|
|
2016-04-03 05:19:11 -05:00
|
|
|
gulp.task("scss:theme-light", function() {
|
|
|
|
return scssPipeline({
|
|
|
|
input: paths.app + "styles/main.scss",
|
|
|
|
output: paths.output + "css/"
|
|
|
|
});
|
2016-02-21 09:42:35 -05:00
|
|
|
});
|
|
|
|
|
2016-04-03 05:19:11 -05:00
|
|
|
// gulp.task("scss:theme-dark", function() {
|
|
|
|
// return scssPipeline({
|
|
|
|
// input: paths.app + "styles/main-theme-dark.scss",
|
|
|
|
// output: paths.output + "css/"
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
|
|
|
|
gulp.task("scss:all", [ // "scss:theme-dark",
|
|
|
|
"scss:theme-light"]);
|
|
|
|
|
|
|
|
gulp.task("dist:cssmin", function() {
|
2016-02-21 09:42:35 -05:00
|
|
|
return gulp.src(paths.output + "css/main.css")
|
|
|
|
.pipe(cssmin())
|
|
|
|
.pipe(gulp.dest(paths.output + "css/"));
|
2015-06-18 12:35:50 -05:00
|
|
|
});
|
|
|
|
|
2016-02-28 03:12:25 -05:00
|
|
|
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
|
2016-04-03 05:19:11 -05:00
|
|
|
});
|
2016-02-28 03:12:25 -05:00
|
|
|
|
|
|
|
return gulp.src(paths.app + "index.mustache")
|
|
|
|
.pipe(tmpl)
|
|
|
|
.pipe(rename("index.html"))
|
|
|
|
.pipe(gulp.dest(paths.output));
|
|
|
|
});
|
|
|
|
|
2016-04-03 05:19:11 -05:00
|
|
|
gulp.task("dist:scss", function(next) {
|
|
|
|
runseq("scss:all", "dist:cssmin", next);
|
2016-02-21 09:42:35 -05:00
|
|
|
});
|
|
|
|
|
2016-04-03 05:19:11 -05:00
|
|
|
gulp.task("dist:clean", function(next) {
|
2016-02-21 13:50:26 -05:00
|
|
|
rimraf(paths.dist, next);
|
2016-02-21 13:42:01 -05:00
|
|
|
});
|
|
|
|
|
2016-02-21 13:50:26 -05:00
|
|
|
gulp.task("clean", function(next) {
|
2016-02-21 11:01:27 -05:00
|
|
|
rimraf(paths.output + "css/", function() {
|
2016-02-21 13:50:26 -05:00
|
|
|
rimraf(paths.output + "js/", function() {
|
|
|
|
rimraf(paths.target, next);
|
|
|
|
});
|
2016-02-21 11:01:27 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-04-03 05:19:11 -05:00
|
|
|
gulp.task("dist:copy", function() {
|
2016-02-21 09:42:35 -05:00
|
|
|
return gulp.src(paths.output + "/**/*.*")
|
|
|
|
.pipe(gulp.dest(paths.dist));
|
|
|
|
});
|
2015-06-18 12:35:50 -05:00
|
|
|
|
|
|
|
// Default
|
2016-02-21 09:42:35 -05:00
|
|
|
gulp.task("dist", function(next) {
|
2016-04-03 05:19:11 -05:00
|
|
|
runseq("template", "dist:scss", "dist:clean", "dist:copy", next);
|
2016-02-21 09:42:35 -05:00
|
|
|
});
|
2015-06-18 12:35:50 -05:00
|
|
|
|
|
|
|
// Watch
|
2016-04-03 05:19:11 -05:00
|
|
|
gulp.task("default", ["scss:all", "template"], function () {
|
|
|
|
gulp.watch(paths.scss, ["scss:all"]);
|
2015-06-18 12:35:50 -05:00
|
|
|
});
|