-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
97 lines (84 loc) · 2.54 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"use strict";
const gulp = require("gulp"),
concat = require("gulp-concat"),
babel = require("gulp-babel"),
uglify = require("gulp-uglify"),
minify = require("gulp-minify-css"),
rename = require("gulp-rename"),
sass = require("gulp-sass"),
maps = require("gulp-sourcemaps"),
nodemon = require("nodemon"),
postcss = require("gulp-postcss"),
autoprefixer = require("autoprefixer"),
pug = require("gulp-pug");
gulp.task("views", function buildHTML() {
return gulp
.src("views/*.pug")
.pipe(pug())
.pipe(gulp.dest("public/"));
});
gulp.task("concatScripts", () => {
return gulp
.src(["app/js/jquery.js", "app/js/main.js"])
.pipe(maps.init())
.pipe(concat("index.js"))
.pipe(maps.write("./"))
.pipe(gulp.dest("app/js"));
});
gulp.task("minifyScripts", ["concatScripts"], () => {
return gulp
.src("app/js/index.js")
.pipe(babel({ presets: ["es2015"] }))
.pipe(uglify())
.pipe(rename("index.min.js"))
.pipe(gulp.dest("public/js"));
});
gulp.task("compileSass", () => {
return gulp
.src("app/scss/application.scss")
.pipe(sass())
.pipe(gulp.dest("app/css"));
});
gulp.task("concatCss", ["compileSass"], () => {
return gulp
.src([
"app/css/normalize.css",
"app/css/font-awesome.css",
"app/css/application.css"
])
.pipe(maps.init())
.pipe(concat("main.css"))
.pipe(maps.write("./"))
.pipe(gulp.dest("app/css"));
});
gulp.task("autoprefixer", ["concatCss"], () => {
return gulp
.src("app/css/main.css")
.pipe(maps.init())
.pipe(postcss([autoprefixer()]))
.pipe(maps.write("./"))
.pipe(gulp.dest("public/css"));
});
gulp.task("minifyCss", ["autoprefixer"], () => {
return gulp
.src("public/css/main.css")
.pipe(minify())
.pipe(rename("main.min.css"))
.pipe(gulp.dest("public/css"));
});
gulp.task("watchFiles", () => {
gulp.watch("app/scss/**/*.scss", ["concatCss"]);
gulp.watch("app/js/main.js", ["concatScripts"]);
});
gulp.task("dev", ["concatCss", "concatScripts", "watchFiles"], () => {
nodemon({ script: "app.js", env: { NODE_ENV: "development" } });
});
gulp.task("copy", () => {
gulp.src("app/css/fonts/*").pipe(gulp.dest("public/css/fonts"));
gulp.src("app/documents/*").pipe(gulp.dest("public/documents"));
gulp.src("app/img/*").pipe(gulp.dest("public/img"));
gulp.src("app/zohoverify/*").pipe(gulp.dest("public/zohoverify"));
gulp.src(["app/*.ico", "app/*.html"]).pipe(gulp.dest("public"));
});
gulp.task("build", ["copy", "views", "minifyScripts", "minifyCss"]);
gulp.task("default", ["dev"]);