-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.esm.js
180 lines (155 loc) · 3.68 KB
/
gulpfile.esm.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*jshint esversion: 8 */
import gulp from 'gulp';
import browserSync from 'browser-sync';
import process from 'process';
import del from 'del';
import jest from 'gulp-jest';
//SASS
import gulpSass from "gulp-sass";
import dartSass from "sass";
const sass = gulpSass(dartSass);
const dest = 'public';
const server = browserSync.create();
function reload(done) {
server.reload();
done();
}
function serve(done) {
server.init({
server: {
baseDir: dest,
index: "index.html"
}
});
done();
}
// Paths and tasks ...
const paths = {
styles: {
src: 'src/sass/**/*.scss',
main: 'src/sass/main.scss',
dest: `${dest}/styles/`
},
scripts: {
src: 'src/**/*.js',
dest: `${dest}`
},
html: {
src: 'src/**/*.html',
dest: `${dest}`
},
manifest: {
src: 'src/**/manifest.*',
dest: `${dest}`
},
images: {
src: 'src/media/images/**/*.{png,gif,jpg}',
dest: `${dest}/media/images/`
},
favicons: {
src: 'src/media/favicons/**/*.{png,ico,svg}',
dest: `${dest}/media/favicons/`
},
animations: {
src: 'src/media/animations/**/*.{png,gif,jpg}',
dest: `${dest}/media/animations/`
},
audio: {
src: 'src/media/audio/**/*.mp3',
dest: `${dest}/media/audio/`
},
video: {
src: 'src/media/video/**/*.{mp4,webm}',
dest: `${dest}/media/video/`
}
};
export const clean = async () => {
del.sync([`${dest}/**`]);
};
export function html() {
return gulp
.src(paths.html.src)
.pipe(gulp.dest(paths.html.dest));
}
export function manifest() {
return gulp
.src(paths.manifest.src)
.pipe(gulp.dest(paths.manifest.dest));
}
export function images() {
return gulp
.src(paths.images.src)
.pipe(gulp.dest(paths.images.dest));
}
export function favicons() {
return gulp
.src(paths.favicons.src)
.pipe(gulp.dest(paths.favicons.dest));
}
export function animations() {
return gulp
.src(paths.animations.src)
.pipe(gulp.dest(paths.animations.dest));
}
export function audio() {
return gulp
.src(paths.audio.src)
.pipe(gulp.dest(paths.audio.dest));
}
export function video() {
return gulp
.src(paths.video.src)
.pipe(gulp.dest(paths.video.dest));
}
export function styles() {
return gulp
.src(paths.styles.main)
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest(paths.styles.dest));
}
export function scripts() {
return gulp
.src(paths.scripts.src)
.pipe(gulp.dest(paths.scripts.dest));
}
export const test = () => {
process.env.NODE_ENV = 'test';
return gulp
.src("tests/**/*test.js")
.pipe(jest({
"preprocessorIgnorePatterns": [
"<rootDir>/dist/", "<rootDir>/node_modules/"
],
"automock": false
}));
};
export const build = (cb) => {
clean();
html();
manifest();
images();
favicons();
animations();
audio();
video();
styles();
scripts();
cb();
};
const watch = () => {
gulp.watch(paths.scripts.src, gulp.series(scripts, reload));
gulp.watch(paths.styles.src, gulp.series(styles, reload));
gulp.watch(paths.html.src, gulp.series(html, reload));
gulp.watch(paths.manifest.src, gulp.series(manifest, reload));
gulp.watch(paths.images.src, gulp.series(images, reload));
gulp.watch(paths.favicons.src, gulp.series(favicons, reload));
gulp.watch(paths.animations.src, gulp.series(animations, reload));
gulp.watch(paths.audio.src, gulp.series(audio, reload));
gulp.watch(paths.video.src, gulp.series(video, reload));
};
export const watchTests = () => {
gulp.watch(["tests/**/*test.js"], test);
};
export const dev = gulp.series(build, serve, watch);
dev.description = 'Build app, start server, watch files, and use browsersync to update pages.';
export default dev;