forked from ageekymonk/hugo-tracks-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (56 loc) · 1.75 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var gulp = require("gulp"),
sass = require("gulp-sass"),
autoprefixer = require("gulp-autoprefixer"),
hash = require("gulp-hash"),
del = require("del");
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var sassDir = 'static/stylesheets',
imgDir = 'static/img',
jsDir = 'static/javascripts';
// Compile SCSS files to CSS
gulp.task("sass", function () {
//Delete our old css files
del(["static/css/**/*"]);
//compile hashed css files
gulp.src(sassDir + "/**/*.scss")
.pipe(sass({
outputStyle : "compressed"
}))
.pipe(autoprefixer({
browsers : ["last 20 versions"]
}))
.pipe(hash())
.pipe(gulp.dest("static/css"))
.pipe(hash.manifest("hash.json"))
.pipe(gulp.dest("data/css"));
});
// Hash images
// gulp.task("img", function () {
// del(["static/img/**/*"]);
// gulp.src(imgDir + "/**/*")
// .pipe(hash())
// .pipe(gulp.dest("static/img"))
// .pipe(hash.manifest("hash.json")
// .pipe(gulp.dest("data/img");
// });
// Hash javascript
gulp.task("js", function () {
del(["static/js/**/*"]);
gulp.src(jsDir + "/**/*")
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(hash())
.pipe(gulp.dest("static/js"))
.pipe(hash.manifest("hash.json"))
.pipe(gulp.dest("data/js"));
});
// Watch asset folder for changes
gulp.task("watch", ["sass"/*, 'img'*/, 'js'], function () {
gulp.watch(sassDir + "/**/*", ["sass"]);
// gulp.watch(imgDir + "/**/*", ["img"]);
gulp.watch(jsDir + "/**/*", ["js"]);
});
// Set watch as default task
gulp.task("default", ["watch"]);