-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (51 loc) · 2.2 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
var gulp = require("gulp"),
sass = require("gulp-sass"),
autoprefixer = require("gulp-autoprefixer"),
hash = require("gulp-hash"),
concat = require('gulp-concat'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
del = require("del"),
sourcemaps = require('gulp-sourcemaps');
// Compile SCSS files to CSS
gulp.task("scss", function() {
del(["static/css/**/*"])
return gulp.src(["src/scss/**/*.scss", "themes/mi-cologne-styleguide/layouts/partials/**/*.scss"])
.pipe(plumber({ errorHandler: notify.onError("Error: <%= error.message %>") }))
.pipe(sass({ outputStyle: "compressed" }))
.pipe(autoprefixer({ browsers: ["last 20 versions"] }))
.pipe(concat('main.css'))
.pipe(hash())
.pipe(gulp.dest("static/css"))
//Create a hash map
.pipe(hash.manifest("hash.json"))
//Put the map in the data directory
.pipe(gulp.dest("data/css"))
});
// Hash images
gulp.task("images", function() {
del(["static/images/**/*"])
gulp.src("src/images/**/*")
.pipe(hash())
.pipe(gulp.dest("static/images"))
.pipe(hash.manifest("hash.json"))
.pipe(gulp.dest("data/images"))
});
// Hash javascript
gulp.task("js", function() {
del(["static/js/**/*"])
gulp.src(["src/js/**/*.js", "themes/mi-cologne-styleguide/layouts/partials/atoms/**/*.js"])
.pipe(concat('main.js'))
.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", ["scss", "images", "js"], function() {
gulp.watch(["src/scss/**/*", "themes/mi-cologne-styleguide/layouts/partials/atoms/**/*", "themes/mi-cologne-styleguide/layouts/partials/molecules/**/*", "themes/mi-cologne-styleguide/layouts/partials/organisms/**/*"], ["scss"])
gulp.watch("src/images/**/*", ["images"])
gulp.watch(["src/js/**/*", "themes/mi-cologne-styleguide/layouts/partials/atoms/**/*", "themes/mi-cologne-styleguide/layouts/partials/molecules/**/*", "themes/mi-cologne-styleguide/layouts/partials/organisms/**/*"], ["js"])
});
// Set watch as default task
gulp.task("default", ["watch"])