-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (41 loc) · 1.19 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
import gulp from 'gulp';
import uglify from 'gulp-uglify';
import cleanCSS from 'gulp-clean-css';
import sourcemaps from 'gulp-sourcemaps';
import rename from 'gulp-rename';
import gulpMode from 'gulp-mode';
const mode = gulpMode();
const paths = {
scripts: {
src: 'js/**/*.js',
dest: 'dist/js/'
},
styles: {
src: 'css/**/*.css',
dest: 'dist/css/'
}
};
function minifyJs() {
return gulp.src(paths.scripts.src)
.pipe(mode.development(sourcemaps.init()))
.pipe(mode.production(uglify()))
.pipe(rename({ suffix: '.min' }))
.pipe(mode.development(sourcemaps.write()))
.pipe(gulp.dest(paths.scripts.dest));
}
function minifyCss() {
return gulp.src(paths.styles.src)
.pipe(mode.development(sourcemaps.init()))
.pipe(mode.production(cleanCSS()))
.pipe(rename({ suffix: '.min' }))
.pipe(mode.development(sourcemaps.write()))
.pipe(gulp.dest(paths.styles.dest));
}
function watchFiles() {
gulp.watch(paths.scripts.src, minifyJs);
gulp.watch(paths.styles.src, minifyCss);
}
const build = gulp.series(gulp.parallel(minifyJs, minifyCss));
const watch = gulp.series(gulp.parallel(minifyJs, minifyCss), watchFiles);
export { watch };
export default build;