-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
164 lines (145 loc) · 3.69 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
const gulp = require("gulp");
const nunjucks = require("gulp-nunjucks");
const autoprefixer = require("autoprefixer");
const sass = require("gulp-sass");
const plumber = require("gulp-plumber");
const postcss = require("gulp-postcss");
const newer = require("gulp-newer");
const rename = require("gulp-rename");
const cssnano = require("cssnano");
const browsersync = require("browser-sync").create();
const del = require("del");
const namesList = [
"Katharina Bieniek",
"Tiffani Fairman",
"Lamont Sanjuan",
"Humberto Daring",
"Phuong Sirmans",
"Horacio Krider",
"Clinton Scala",
"Douglass Landes",
"Karisa Stangl",
"Caroll Traverso",
"Dewayne Shontz",
"Buford Westra",
"Slyvia Cora",
"Malisa Shehan",
"Jeremy Dejulio",
"Jonnie Greig",
"Christinia Ricketson",
"Frida Earnest",
"Hector Hutchens",
"Patrice Barkett",
"Yuonne Grunden",
"Celestina Pollack",
"Cleora Castilleja",
"Theresa Shives",
"Wilford Shrout",
"Kimbra Manges",
"Grayce Morais",
"Merlyn Blocher",
"Gidget Mcauley",
"Neida Hagerty"
];
const namesListFormatted = namesList.join(`, `)
function bSync(done) {
browsersync.init({
server: {
baseDir: "./dist/"
},
port: 3000
});
done();
}
function browserSyncReload(done) {
browsersync.reload();
done();
}
function clean() {
return del(["./dist/assets/"]);
}
function images() {
return gulp
.src("./assets/img/**/*")
.pipe(newer("./dist/assets/img"))
.pipe(gulp.dest("./dist/assets/img"));
}
function compileCss() {
return gulp
.src("./assets/scss/**/*.scss")
.pipe(plumber())
.pipe(sass({ outputStyle: "expanded" }))
.pipe(gulp.dest("./dist/assets/css/"))
.pipe(rename({ suffix: ".min" }))
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(gulp.dest("./dist/assets/css/"))
.pipe(browsersync.stream());
}
function css() {
return gulp
.src("./assets/css/**/*.css")
.pipe(plumber())
.pipe(gulp.dest("./dist/assets/css/"))
.pipe(browsersync.stream());
}
function js() {
return gulp
.src(["./assets/js/**/*"])
.pipe(plumber())
.pipe(gulp.dest("./dist/assets/js/"))
.pipe(browsersync.stream());
}
function templates() {
return gulp
.src("./src/**/*.html")
.pipe(nunjucks.compile({ namesList, namesListFormatted }))
.pipe(gulp.dest("./dist"));
}
function watchFiles() {
gulp.watch("./assets/scss/**/*", compileCss);
gulp.watch("./assets/css/**/*", css);
gulp.watch("./assets/js/**/*", js);
gulp.watch("./assets/img/**/*", images);
gulp.watch("./src/**/*.html", templates);
}
const build = gulp.series(clean, gulp.parallel(css, compileCss, images, js));
const watch = gulp.parallel(watchFiles, bSync);
// export tasks
exports.images = images;
exports.css = css;
exports.js = js;
exports.clean = clean;
exports.build = build;
exports.watch = watch;
exports.default = build;
// gulp.task("js", function() {
// return gulp
// .src("assets/js/*js")
// .pipe(browserify())
// .pipe(uglify())
// .pipe(gulp.dest("dist/js"));
// });
// gulp.task("watch", ["js"], function(done) {
// browserSync.reload();
// done();
// });
// function styles() {
// return gulp.src('./assets/scss/**/*.scss')
// .pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
// .pipe(autoprefixer({ remove: false }))
// .pipe(gulp.dest('./assets/css'))
// .pipe(bsync.stream());
// }
// gulp.task("default", ["js"], function() {
// browserSync.init({
// server: {
// baseDir: "./"
// }
// });
// gulp.watch("assets/js/*.js", ["watch"]);
// });
// gulp.task("nunjucks", ["html"], function() {
// return gulp.src('templates/*.html')
// .pipe(nunjucks.compile())
// .pipe(gulp.dest('dist'))
// })