-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (57 loc) · 1.65 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
/**
* Gulp Configuration
*/
// Dependencies
// --------------------------------------------------
const gulp = require("gulp"),
babel = require("gulp-babel"),
concat = require("gulp-concat"),
plumber = require("gulp-plumber"),
sourceMaps = require("gulp-sourcemaps"),
uglify = require("gulp-uglify"),
minifyCss = require("gulp-minify-css"),
preFixer = require("gulp-autoprefixer");
// Global Variables
// --------------------------------------------------
const scriptsPath = "assets/js/**/*.js",
stylesPath = "assets/css/**/*.css",
distPath = "assets/dist";
// Tasks
// --------------------------------------------------
// Styles task
gulp.task("styles", function() {
return gulp.src(stylesPath)
.pipe(plumber(function(err) {
console.log("Styles task error...");
console.log(err);
this.emit("end");
}))
.pipe(sourceMaps.init())
.pipe(preFixer())
.pipe(concat("styles.css"))
.pipe(minifyCss())
.pipe(sourceMaps.write())
.pipe(gulp.dest(distPath));
});
// Scripts task
gulp.task("scripts", function() {
return gulp.src(scriptsPath)
.pipe(plumber(function(err) {
console.log("Scripts task error...");
console.log(err);
this.emit("end");
}))
.pipe(sourceMaps.init())
.pipe(babel({
presets: ["@babel/preset-env"]
}))
.pipe(concat("scripts.js"))
.pipe(uglify())
.pipe(sourceMaps.write())
.pipe(gulp.dest(distPath))
});
// Watch task
gulp.task("watch", function() {
gulp.watch(stylesPath, ["styles"]);
gulp.watch(scriptsPath, ["scripts"]);
});