-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
80 lines (73 loc) · 2.22 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
const gulp = require("gulp");
const notify = require("gulp-notify");
const plumber = require("gulp-plumber");
const stylus = require("gulp-stylus");
const autoprefixer = require("gulp-autoprefixer");
const pug = require("gulp-pug");
const browserSync = require("browser-sync");
//setting : paths
const paths = {
"styl": "./htdocs_dev/styl/",
"css": "./htdocs/assets/css/",
"pug": "./htdocs_dev/pug/",
"html": "./htdocs/",
"js_dev": "./htdocs_dev/js/",
"js_dist": "./htdocs/assets/js/",
"img_dev": "./htdocs_dev/img/",
"img_dist": "./htdocs/assets/img/"
}
//setting : Stylus Options
const stylusOptions = {
//compress: true
}
//setting : Pug Options
const pugOptions = {
pretty: true
}
//pug
gulp.task("pug", () => {
return gulp.src([paths.pug + "**/*.pug", "!" + paths.pug + "**/_*.pug"])
.pipe(plumber({ errorHandler: notify.onError("おだやかじゃないわね...!!:<%= error.message %>") }))
.pipe(pug(pugOptions))
.pipe(gulp.dest(paths.html));
});
//Stylus
gulp.task("stylus", () => {
gulp.src([paths.styl + "**/*.styl", "!" + paths.styl + "**/_*.styl"])
.pipe(plumber({ errorHandler: notify.onError("おだやかじゃないっ!:<%= error.message %>") }))
.pipe(stylus(stylusOptions))
.pipe(autoprefixer())
.pipe(gulp.dest(paths.css));
});
//JS
gulp.task('js', () => {
gulp.src([paths.js_dev + "**/*.js", "!" + paths.js_dev + "**/_*.js"])
.pipe(gulp.dest(paths.js_dist));
});
gulp.task('img', () => {
gulp.src(paths.img_dev + "**/*")
.pipe(gulp.dest(paths.img_dist));
});
//Browser sync
gulp.task("browser-sync", () => {
browserSync({
server: {
baseDir: paths.html
}
});
gulp.watch(paths.html + "**/*.html", ["reload"]);
gulp.watch(paths.css + "**/*.css", ["reload"]);
gulp.watch(paths.js_dist + "**/*.js", ["reload"]);
gulp.watch(paths.img_dist + "**/*", ["reload"]);
});
gulp.task("reload", () => {
browserSync.reload();
})
//watch
gulp.task("watch", () => {
gulp.watch(paths.styl + "**/*.styl", ["stylus"]);
gulp.watch([paths.pug + "**/*.pug", "!" + paths.pug + "**/_*.pug"], ["pug"]);
gulp.watch(paths.js_dev + "**/*.js", ["js"]);
gulp.watch(paths.img_dev + "**/*", ["img"]);
});
gulp.task("default", ["browser-sync", "watch", "img"]);