-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
56 lines (51 loc) · 1.49 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
"use strict";
const gulp = require("gulp");
const babel = require("gulp-babel");
const sass = require("gulp-sass")(require("sass"));
const uglifycss = require("gulp-uglifycss");
const sourcemaps = require("gulp-sourcemaps");
const concat = require("gulp-concat");
const autoprefixer = require("autoprefixer");
const postcss = require("gulp-postcss");
function compileSass() {
return gulp
.src("./app/scss/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest("./app/assets/css"));
}
function processCSS() {
return gulp
.src("./app/assets/css/*.css")
.pipe(sourcemaps.init())
.pipe(postcss([autoprefixer()]))
.pipe(uglifycss({ uglyComments: true }))
.pipe(sourcemaps.write())
.pipe(gulp.dest("./dist/"));
}
function compileJS() {
return gulp
.src("./app/js/**/*.js")
.pipe(sourcemaps.init())
.pipe(
babel({
presets: ["@babel/env"],
})
)
.pipe(concat("all.js"))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("./dist/js"));
}
exports.default = gulp.parallel(
function watchSCSS() {
gulp.watch(
"./app/scss/**/*.scss",
{ ignoreInitial: false },
gulp.series(compileSass, processCSS)
);
},
function watchJS() {
gulp.watch("./app/js/**/*.js", { ignoreInitial: false }, compileJS);
}
);