Created
September 4, 2014 15:50
-
-
Save Deiru2k/471b6318839727e088d6 to your computer and use it in GitHub Desktop.
Gulpfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
gulp clean && gulp build && gulp templates | |
OH GOD WHY SO JAVASCRIPT | |
*/ | |
"use strict" | |
var gulp = require("gulp"), | |
$ = require("gulp-load-plugins")(); | |
var minifyHtml = require("gulp-minify-html"); | |
gulp.task("clean", function() { | |
return gulp.src([".tmp", "dist"], { read: false }) | |
.pipe($.rimraf()) | |
}); | |
gulp.task("coffee", function() { | |
return gulp.src(["app/scripts/**/*.coffee"]) | |
.pipe($.coffee()) | |
.pipe($.ngAnnotate()) | |
.pipe($.uglify()) | |
.pipe(gulp.dest(".tmp/scripts")) | |
}); | |
gulp.task("sass", function() { | |
return gulp.src("app/styles/*.scss") | |
.pipe($.sass({ outputStyle: "compressed" })) | |
.pipe(gulp.dest(".tmp/styles")) | |
}); | |
gulp.task("fonts", function() { | |
return gulp.src("app/fonts/**/*.*") | |
.pipe(gulp.dest("dist/fonts")) | |
}); | |
gulp.task("images", function() { | |
return gulp.src("app/images/**/*.svg") | |
.pipe($.svgmin()) | |
.pipe(gulp.dest("dist/images")); | |
return gulp.src("app/images/**/*.{jpg,png}") | |
.pipe(gulp.dest("dist/images")); | |
}); | |
gulp.task("templates", function() { | |
var assets = $.useref.assets(); | |
return gulp.src("app/*.html") | |
.pipe(assets) | |
.pipe(assets.restore()) | |
.pipe($.useref()) | |
.pipe(gulp.dest("dist")); | |
return gulp.src("app/views/**/*.html") | |
.pipe(minifyHtml({empty: true})) | |
.pipe(gulp.dest("dist/views")); | |
}); | |
gulp.task("build", ["sass", "coffee", "fonts", "images"]) | |
gulp.task("watch", ["clean", "sass"], function() { | |
$.livereload.listen(); | |
var express = require("express"), | |
app = express(); | |
app.use(express.static(__dirname + "/app")); | |
app.use(express.static(__dirname + "/.tmp")); | |
app.use(require('connect-livereload')()); | |
app.listen(3000); | |
gulp.watch(["app/*.html", "app/views/**/*.html"]).on('change', $.livereload.changed); | |
gulp.watch("app/styles/**/*.scss", ["sass"]).on('change', $.livereload.changed); | |
gulp.watch("app/scripts/**/*.coffee", ["coffee"]).on('change', $.livereload.changed); | |
gulp.watch("app/images/**/*", ["images"]).on('change', $.livereload.changed); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment