-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulp4file.js
executable file
·74 lines (67 loc) · 1.47 KB
/
gulp4file.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
// Gulp.js configuration
"use strict";
//source and build folders
const dir = {
src: "./assets/",
build: "./",
root: "./"
},
// Gulp and plugins
gulp = require("gulp"),
gutil = require("gulp-util"),
sass = require("gulp-sass"),
postcss = require("gulp-postcss"),
sourcemaps = require("gulp-sourcemaps");
// Browser-sync
var browsersync = false;
//- CSS
//config
var css = {
src: dir.src + "scss/*.scss",
watch: dir.src + "scss/**/*.scss", //*/
build: dir.build,
sassOpts: {
outputStyle: "expanded",
// imagePath : images.build,
precision: 3,
errLogToConsole: true
},
processors: [
require("postcss-assets")({
// loadPaths: ['images/'],
basePath: dir.build
// baseUrl: "/wp-content/themes/jackalope/"
}),
require("autoprefixer")(),
require("css-mqpacker"),
require("cssnano")
]
};
// CSS processing
gulp.task(
"css",
gulp.series(() => {
return gulp
.src(css.src)
.pipe(sourcemaps.init())
.pipe(sass(css.sassOpts))
.pipe(postcss(css.processors))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest(css.build))
.pipe(
browsersync
? browsersync.reload({
stream: true
})
: gutil.noop()
);
})
);
//- Watch
gulp.task(
"watch",
gulp.series("css", done => {
gulp.watch(css.watch, gulp.series("css"));
done();
})
);