forked from jakewies/hugo-theme-codex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (40 loc) · 1.24 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
var gulp = require("gulp");
var babel = require("gulp-babel");
var stylus = require("gulp-stylus");
var sourcemaps = require("gulp-sourcemaps");
var autoprefixer = require("gulp-autoprefixer");
var gulpIf = require("gulp-if");
var gutil = require("gulp-util");
const isDev = () => gutil.env.env === "dev";
gulp.task("styles", function () {
return gulp
.src("src/styles/pages/*.styl")
.pipe(gulpIf(isDev(), sourcemaps.init()))
.pipe(
stylus({
compress: true,
})
)
.pipe(autoprefixer())
.pipe(gulpIf(isDev(), sourcemaps.write()))
.pipe(gulp.dest("static/css"));
});
gulp.task("js", function () {
return gulp
.src("src/js/**/*.js")
.pipe(
babel({
presets: ["@babel/preset-env"],
})
)
.pipe(gulp.dest("static/js"));
});
gulp.task("watch", function () {
gulp.watch("src/styles/**/*.styl", gulp.series("styles"));
gulp.watch("src/js/**/*.js", gulp.series("js"));
});
// The default task is run on yarn watch:assets. This will build styles and js
// before watching the src/styles and src/js directoryies
gulp.task("default", gulp.series(gulp.parallel("styles", "js"), "watch"));
// The build task is run on yarn build:assets
gulp.task("build", gulp.parallel("styles", "js"));