-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (40 loc) · 1.3 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 { join, resolve } = require("path");
const gulp = require("gulp");
const postcss = require("gulp-postcss");
const sass = require("gulp-sass")(require("sass"));
const sourcemaps = require("gulp-sourcemaps");
const terser = require("gulp-terser");
const SOURCE_DIR = resolve(__dirname, "src");
const OUTPUT_DIR = resolve(__dirname, "public");
function html() {
return gulp.src(join(SOURCE_DIR, "index.html")).pipe(gulp.dest(OUTPUT_DIR));
}
function css() {
return gulp
.src(join(SOURCE_DIR, "scss", "*.scss"))
.pipe(sourcemaps.init())
.pipe(sass.sync().on("error", sass.logError))
.pipe(postcss([require("autoprefixer"), require("postcss-csso")]))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(OUTPUT_DIR));
}
function js() {
return gulp
.src(join(SOURCE_DIR, "main.js"))
.pipe(sourcemaps.init())
.pipe(terser({ ecma: 5 }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(OUTPUT_DIR));
}
function static() {
return gulp
.src(join(SOURCE_DIR, "static", "**", "*"))
.pipe(gulp.dest(OUTPUT_DIR));
}
exports.default = gulp.parallel(html, css, js, static);
exports.watch = () => {
gulp.watch(join(SOURCE_DIR, "index.html"), html);
gulp.watch(join(SOURCE_DIR, "scss", "*.scss"), css);
gulp.watch(join(SOURCE_DIR, "main.js"), js);
gulp.watch(join(SOURCE_DIR, "static", "**", "*"), static);
};