forked from Louie787/Magazine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
106 lines (96 loc) · 3.05 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const gulp = require("gulp"),
sass = require("gulp-sass"),
autoprefixer = require("gulp-autoprefixer"),
uglify = require("gulp-uglify-es").default,
imagemin = require("gulp-imagemin"),
concat = require("gulp-concat"),
del = require("del"),
browserSync = require("browser-sync");
gulp.task("clean", async function() {
del.sync("./dist");
});
gulp.task("browser-sync", function() {
browserSync.init({
server: {
baseDir: "./"
},
notify: false,
online: true,
tunnel: true,
tunnel: "test" // Demonstration page: http://test.localtunnel.me
});
});
gulp.task("html", function() {
return gulp.src("./*.html").pipe(browserSync.reload({ stream: true }));
});
gulp.task("style", function() {
return gulp
.src([
"./node_modules/normalize.css/normalize.css",
"./node_modules/slick-carousel/slick/slick.scss",
"./node_modules/magnific-popup/dist/magnific-popup.css",
"./src/scss/**/*.scss"
])
.pipe(
sass({
outputStyle: "compressed"
})
)
.pipe(
autoprefixer({
grid: "autoplace",
overrideBrowserslist: ["last 10 version"],
cascade: false
})
)
.pipe(concat("style.min.css"))
.pipe(gulp.dest("./css"))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task("script", function() {
return gulp
.src([
"./node_modules/slick-carousel/slick/slick.min.js",
"./node_modules/magnific-popup/dist/jquery.magnific-popup.min.js",
"./node_modules/gsap/src/minified/TweenMax.min.js",
"./node_modules/gsap/src/minified/plugins/CSSRulePlugin.min.js",
"./node_modules/scrollmagic/scrollmagic/uncompressed/ScrollMagic.js",
"./node_modules/scrollmagic/scrollmagic/uncompressed/plugins/animation.gsap.js",
"./src/js/**/*.js"
])
.pipe(concat("script.min.js"))
.pipe(uglify())
.pipe(gulp.dest("./js"))
.pipe(browserSync.reload({ stream: true }));
});
gulp.task("img", function() {
return gulp
.src("./src/img/**/*")
.pipe(
imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.jpegtran({ progressive: true }),
imagemin.optipng({ optimizationLevel: 5 })
])
)
.pipe(gulp.dest("./img"))
.pipe(browserSync.stream());
});
gulp.task("export", function() {
const buildHtml = gulp.src("./*.html").pipe(gulp.dest("./dist"));
const buildFonts = gulp.src("./fonts/**/*.*").pipe(gulp.dest("./dist/fonts"));
const buildImg = gulp.src("./img/**/*.*").pipe(gulp.dest("./dist/img"));
const buildCss = gulp.src("./css/**/*.css").pipe(gulp.dest("./dist/css"));
const buildJs = gulp.src("./js/**/*.js").pipe(gulp.dest("./dist/js"));
});
gulp.task("watch", function() {
gulp.watch("./*.html", gulp.parallel("html"));
gulp.watch("./src/scss/**/*.scss", gulp.parallel("style"));
gulp.watch("./src/js/**/*.js", gulp.parallel("script"));
gulp.watch("./src/img/**/*.*", gulp.parallel("img"));
});
gulp.task("build", gulp.series("clean", "export"));
gulp.task(
"default",
gulp.parallel("html", "style", "script", "img", "browser-sync", "watch")
);