-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
68 lines (59 loc) · 1.98 KB
/
gulpfile.js
File metadata and controls
68 lines (59 loc) · 1.98 KB
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
65
66
67
68
// Requiring gulp and gulp plugins
var gulp = require("gulp");
var plugins = require("gulp-load-plugins")({DEBUG: true});
// Gulp webserver
gulp.task("webserver", function () {
"use strict";
gulp.src("./")
.pipe(plugins.webserver({
livereload: true,
open: true,
fallback: "index.html"
}));
});
// Concat javascript and put into a file named production.js in the js folder
gulp.task("concatScripts", function () {
"use strict";
return gulp.src("src/*.js")
.pipe(plugins.sourcemaps.init())
.pipe(plugins.concat("production.js"))
.pipe(plugins.sourcemaps.write("./"))
.pipe(gulp.dest("js"))
.pipe(plugins.livereload());
});
// Minify javascript and put into a keep it at production.js in the js folder
gulp.task("minifyScripts", ["concatScripts"], function () {
"use strict";
return gulp.src("js/production.js")
.pipe(plugins.uglify())
.pipe(gulp.dest("js"))
.pipe(plugins.livereload());
});
// Compile sass automatically
gulp.task("compileSass", function () {
"use strict";
gulp.src("src/main.scss")
.pipe(plugins.sourcemaps.init())
// autoprefixer to add prefixes for older browsers
.pipe(plugins.autoprefixer())
.pipe(plugins.sass())
.pipe(plugins.sourcemaps.write("./"))
.pipe(gulp.dest("css"))
// allows automatic css injecting
.pipe(plugins.livereload());
});
// Watch task to watch for changes to sass and js
gulp.task("watch", ["compileSass", "minifyScripts", "concatScripts"], function () {
"use strict";
plugins.livereload.listen();
// Watch sass/js for changes
gulp.watch("src/*.scss", ["compileSass"]);
gulp.watch("src/*.js", ["concatScripts", "minifyScripts"]);
});
gulp.task("build", ["webserver", "concatScripts", "minifyScripts", "compileSass", "watch"], function () {
"use strict";
});
gulp.task("default", function () {
"use strict";
gulp.start("build");
});