-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
80 lines (72 loc) · 1.98 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var gulp = require("gulp");
var sass = require("gulp-sass");
var cleanCSS = require("gulp-clean-css");
var rename = require("gulp-rename");
var minify = require("gulp-minify");
var browserSync = require("browser-sync").create();
var postcss = require("gulp-postcss");
var autoprefixer = require("autoprefixer");
gulp.task("default", ["watch", "browser-sync-proxy"]);
gulp.task("watch", function() {
gulp.watch(
["./public/sass/*/*.sass", "./public/sass/*.sass"],
["sass", "minify-css"],
browserSync.reload
);
gulp.watch(
[
"./public/javascripts/index.js",
"./public/javascripts/index2.js",
"./public/javascripts/index3.js"
],
["minify-js"],
browserSync.reload
);
gulp.watch(["./views/*.pug", "./views/**/*.pug"], browserSync.reload);
});
gulp.task("autoprefixer", function() {
return gulp
.src("./public/stylesheets/main.css")
.pipe(postcss([autoprefixer({ browsers: ["last 2 versions"] })]))
.pipe(gulp.dest("./public/stylesheets/"));
});
gulp.task("minify-css", ["autoprefixer"], function() {
gulp
.src("./public/stylesheets/main.css")
.pipe(cleanCSS({ compatibility: "ie8", keepBreaks: false }))
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("public/stylesheets/"));
});
gulp.task("sass", function() {
gulp
.src("./public/sass/main.sass")
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest("./public/stylesheets/"));
});
gulp.task("minify-js", function() {
gulp
.src([
"./public/javascripts/index.js",
"./public/javascripts/index2.js",
"./public/javascripts/index3.js"
])
.pipe(
minify({
ext: {
min: ".min.js"
},
ignoreFiles: [".combo.js", ".min.js"]
})
)
.pipe(gulp.dest("./public/javascripts/"));
});
gulp.task("browser-sync-proxy", function() {
browserSync.init({ proxy: "http://localhost:8080" });
});
gulp.task("browser-sync", function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});