-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
122 lines (108 loc) · 2.97 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
"use strict";
// Importando plugins utilizados no projeto
const gulp = require("gulp");
const sass = require("gulp-sass")(require("sass"));
sass.compiler = require("node-sass");
const cssmin = require("gulp-clean-css");
const concat = require("gulp-concat");
const rename = require("gulp-rename");
const uglify = require("gulp-uglifyes");
// const imagemin = require("gulp-imagemin");
const htmlreplace = require("gulp-html-replace");
const htmlmin = require("gulp-htmlmin");
// Compilar SASS gerando CSS na pasta SRC
function compilaSASS() {
return gulp
.src(["src/scss/styles.scss"])
.pipe(sass())
.pipe(gulp.dest("src/css"));
}
//Minificar/concatenar/renomear arquivos CSS da pasta SRC para pasta DIST
function optimizeCSS() {
return gulp
.src(["src/css/**/*.css"])
.pipe(cssmin())
.pipe(concat("styles.css"))
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("dist/css"));
}
// Minificar/concatenar/renomear arquivos JS Geral Dev
function optimizeJSGeneral() {
return gulp
.src(["src/js/**/*.js"])
.pipe(uglify())
.pipe(concat("scripts.js"))
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("dist/js"));
}
// Minificar/concatenar/renomear arquivos JS Carousel Dev
// function optimizeJSCarousel() {
// return gulp
// .src(["src/js/carousel/**/*.js"])
// .pipe(uglify())
// .pipe(concat("carousel.js"))
// .pipe(rename({ suffix: ".min" }))
// .pipe(gulp.dest("dist/js"));
// }
// Minificar/concatenar/renomear arquivos JS Form Dev
// function optimizeJSForm() {
// return gulp
// .src(["src/js/form/**/*.js"])
// .pipe(uglify())
// .pipe(concat("form.js"))
// .pipe(rename({ suffix: ".min" }))
// .pipe(gulp.dest("dist/js"));
// }
// Otimizar arquivos de imagens Dev
// function optimizeIMG() {
// return gulp
// .src("src/assets/**/*")
// .pipe(imagemin())
// .pipe(gulp.dest("dist/assets"));
// }
// Renomear links de CSS e JS minificados carregados no HTML Dev
function replaceHTML() {
return gulp
.src(["src/*.html"])
.pipe(
htmlreplace({
allcss: "css/styles.min.css",
alljs: "js/scripts.min.js",
// carousel: "js/carousel.min.js"
})
)
.pipe(gulp.dest("dist/"));
}
// Otimizar arquivos HTML
function optimizeHTML() {
return gulp
.src(["dist/*.html"])
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest("dist/"));
}
// Copiar arquivos
function copyFiles() {
return (
gulp.src(["src/assets/*"]).pipe(gulp.dest("dist/assets/"))
// gulp.src(["src/js/form/**/*"]).pipe(gulp.dest("dist/js/"))
);
}
// Agrupar tarefas a serem monitoradas
function watch() {
gulp.watch("src/scss/**/*.scss", compilaSASS);
// gulp.watch("src/css/**/*.css", optimizeCSS);
}
// Agrupar e executar tarefas
const build = gulp.parallel(
compilaSASS,
optimizeCSS,
optimizeJSGeneral,
// optimizeJSCarousel,
// optimizeJSForm,
// optimizeIMG,
replaceHTML,
optimizeHTML,
copyFiles,
// watch
);
gulp.task("default", build);