forked from biolab/orange-hugo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (41 loc) · 1.14 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
const gulp = require("gulp");
const sass = require("gulp-sass");
const sourcemaps = require("gulp-sourcemaps");
const rename = require("gulp-rename");
const postcss = require("gulp-postcss");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const plumber = require("gulp-plumber");
const paths = {
styles: {
src: "./dev/scss/**/*.scss",
dest: "./static/build/css/",
},
};
// Convert scss to css, auto-prefix and rename into styles.min.css
const styles = () =>
gulp
.src(paths.styles.src)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(
rename({
basename: "styles",
suffix: ".min",
})
)
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(paths.styles.dest))
// Watches all .scss changes and executes the corresponding task
function watchFiles() {
gulp.watch(paths.styles.src, styles);
}
const build = gulp.series(gulp.parallel(styles));
const watch = gulp.series(build, watchFiles);
// exports.clean = clean;
exports.styles = styles;
exports.watch = watch;
exports.build = build;
exports.default = watch;