-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
78 lines (68 loc) · 1.67 KB
/
Copy pathgulpfile.babel.js
File metadata and controls
78 lines (68 loc) · 1.67 KB
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
import gulp from 'gulp';
import sass from 'gulp-sass';
import babel from 'gulp-babel';
import uglify from 'gulp-uglify';
import cleanCSS from 'gulp-clean-css';
import del from 'del';
import autoprefixer from 'gulp-autoprefixer';
import sourcemaps from 'gulp-sourcemaps';
import browserSync from 'browser-sync';
const server = browserSync.create();
const paths = {
styles: {
src: 'src/sass/**/*.{sass,scss}',
dest: 'dist/css/'
},
scripts: {
src: ['src/js/**/*.js', '!src/js/vendor/**/*.js'],
dest: 'dist/js/'
}
};
/*
* For small tasks you can export arrow functions
*/
export const clean = () => del([ 'assets' ]);
/*
* You can also declare named functions and export them as tasks
*/
export function styles() {
return gulp.src(paths.styles.src)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer( 'last 4 version' ))
.pipe(cleanCSS())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.styles.dest));
}
export function scripts() {
return gulp.src(paths.scripts.src, { sourcemaps: true })
.pipe(babel())
.pipe(uglify())
.pipe(gulp.dest(paths.scripts.dest));
}
/*
* You could even use `export as` to rename exported tasks
*/
function watchFiles() {
gulp.watch(paths.scripts.src, gulp.series(scripts, reload));
gulp.watch(paths.styles.src, gulp.series(styles, reload));
}
const dev = gulp.series(serve, watchFiles);
export { dev as watch };
function reload(done) {
server.reload();
done();
}
function serve(done) {
server.init({
server: {
baseDir: './'
}
});
done();
}
const build = gulp.series(clean, serve, gulp.parallel(styles, scripts));
/*
* Export a default task
*/
export default build;