-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
84 lines (73 loc) · 2.11 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
const gulp = require("gulp");
const connect = require("gulp-connect");
const watch = require("gulp-watch");
const sass = require("gulp-sass");
const babel = require("gulp-babel");
const uglify = require("gulp-uglify");
const del = require("del");
const postcss = require("gulp-postcss");
const tailwindcss = require("tailwindcss");
// Default settings for gulpfile
var project = {
buildSrc: "./src",
buildDest: "./dist"
};
// Watch for file changes
gulp.task("watch", done => {
// Watch SASS files and compile when changed
gulp.watch(
project.buildSrc + "/assets/stylesheets/**/*.scss",
gulp.series("stylesheets")
);
// Watch JS files and compile when changed
// gulp.watch(
// project.buildSrc + "/assets/scripts/**/*.js",
// gulp.series("scripts")
// );
/**
Using gulp-watch as standard gulp
doesn't track files the same way.
See: https://stackoverflow.com/questions/42890414/how-to-setup-gulp-watch-with-gulp-connect-livereload
*/
watch(project.buildDest).pipe(connect.reload());
done();
});
// Compile Scripts (Simple, No ES6 imports)
// gulp.task("scripts", done => {
// gulp
// .src(project.buildSrc + "/assets/scripts/app.js")
// .pipe(
// babel({
// presets: ["@babel/env"]
// })
// )
// .pipe(uglify())
// .pipe(gulp.dest(project.buildDest + "/assets/scripts"))
// .pipe(connect.reload());
// done();
// });
// Compile SASS
gulp.task("stylesheets", done => {
gulp
.src(project.buildSrc + "/assets/stylesheets/app.scss")
.pipe(sass().on("error", sass.logError))
.pipe(postcss([tailwindcss("./tailwind.js"), require("autoprefixer")]))
.pipe(gulp.dest(project.buildSrc + "/_includes/stylesheets"));
done();
});
// Lightweight development server
gulp.task("server", done => {
connect.server({
root: project.buildDest,
livereload: true
});
done();
});
// Clean build dir
gulp.task("clean", function() {
return del([project.buildDest + "/**/*"]);
});
// Build task
gulp.task("build", gulp.parallel("clean", "stylesheets"));
// Development task
gulp.task("dev", gulp.parallel("watch", "stylesheets", "server"));