forked from kurtobando/simple-tags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (45 loc) · 1.16 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
// https://cobwwweb.com/compile-es6-code-gulp-babel-part-1
const gulp = require('gulp')
const babel = require('gulp-babel')
const plumber = require('gulp-plumber')
const minify = require('gulp-minify')
const sass = require('gulp-sass')
const postcss = require('gulp-postcss')
const autoprefixer = require('autoprefixer')
// source and build
const source = {
'script' : 'source/script/*.js',
'style' : 'source/style/*.scss'
}
const build = {
'js' : 'build/js/',
'css' : 'build/css/'
}
// build JS
gulp.task( 'build-js', function() {
return gulp.src( source.script )
.pipe( plumber() )
.pipe( babel(
{
presets: [
[ '@babel/env', { modules: false } ]
]
}
))
.pipe( minify() )
.pipe( gulp.dest( build.js ) )
})
// build SCSS
gulp.task( 'build-sass', function() {
return gulp.src( source.style )
.pipe( sass() )
.pipe( postcss( [ autoprefixer ] ) )
.pipe( gulp.dest( build.css ) )
});
// Watch
gulp.task( 'watch', function() {
gulp.watch( source.style, gulp.series( 'build-sass' ) )
gulp.watch( source.script, gulp.series( 'build-js' ) )
})
// build Default
gulp.task( 'default', gulp.series( 'build-sass', 'build-js' ) )