-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
87 lines (77 loc) · 2.75 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
85
86
87
const gulp = require("gulp");
const pug = require("gulp-pug");
const sass = require("gulp-sass");
const browserSync = require("browser-sync");
const concat = require("gulp-concat");
const babel = require("gulp-babel");
const sourcemaps = require("gulp-sourcemaps");
const cleanCSS = require("gulp-clean-css");
const rename = require("gulp-rename");
const autoprefixer = require("gulp-autoprefixer");
gulp.task("pug", () => {
return gulp
.src("app/pug/*.pug")
.pipe(pug({ pretty: true }))
.pipe(gulp.dest("app"))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task("styles", () => {
return gulp
.src("app/assets/templates/default/sass/**/*.+(sass|scss)")
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: "expanded" }))
.pipe(rename({ suffix: ".min", prefix: "" }))
.pipe(autoprefixer(["last 15 versions"], { cascade: true }))
.pipe(cleanCSS({ level: { 1: { specialComments: 0 } } }))
.pipe(gulp.dest("app/assets/templates/default/css"))
.pipe(sourcemaps.write())
.pipe(browserSync.reload({ stream: true }));
});
gulp.task("js", () => {
return gulp
.src([
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js",
// "node_modules/owl.carousel/dist/owl.carousel.min.js",
"app/assets/templates/default/js/main/**/*.js"
])
.pipe(concat("scripts.min.js"))
.pipe(gulp.dest("app/assets/templates/default/js"))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task("browser-sync", () => {
browserSync.init({
server: {
baseDir: "app",
},
notify: false,
open: true,
});
});
gulp.task("watch", () => {
gulp.watch("app/pug/**/*.pug", gulp.parallel("pug"));
gulp.watch("app/assets/templates/default/sass/**/*.+(sass|scss)", gulp.parallel("styles"));
gulp.watch(["assets/templates/default/libs/**/*.js", "app/assets/templates/default/js/main/**/*.js"], gulp.parallel("js"));
gulp.watch("app/*.html", browserSync.reload());
});
gulp.task("default", gulp.parallel("pug", "styles", "js", "browser-sync", "watch"));
gulp.task("build", gulp.series("styles", "js", "pug", async () => {
gulp.src("app/assets/templates/default/**/*").pipe(gulp.dest("dist/assets/templates/default"));
// если fenom
if (process.argv.includes("--el")) {
gulp.src(["app/*.html", "!app/index.html"]).pipe(gulp.dest("elements/templates"));
gulp
.src("app/index.html")
.pipe(rename({ basename: "main" }))
.pipe(gulp.dest("elements/templates"));
gulp
.src("app/pug/chunks/**/*.pug")
.pipe(pug({ pretty: true }))
.pipe(rename({ extname: ".tpl" }))
.pipe(gulp.dest("elements/chunks"));
} else {
gulp.src("app/*.html").pipe(gulp.dest("dest"));
}
return;
})
);