This repository has been archived by the owner on Nov 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 401
/
gulpfile.babel.js
78 lines (68 loc) · 1.48 KB
/
gulpfile.babel.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
import {
src,
dest,
watch as watchSrc,
parallel,
series
} from 'gulp'
import babel from 'gulp-babel'
import del from 'del'
import autoprefixer from 'gulp-autoprefixer'
import image from 'gulp-image'
import sass from 'gulp-sass'
// Directories
const SRC_DIR = 'app/src'
const DIST_DIR = 'app/dist'
// Source files
const JS_GLOB = `${SRC_DIR}/**/*.js`
const CSS_GLOB = `${SRC_DIR}/**/*.scss`
const HTML_GLOB = `${SRC_DIR}/**/*.html`
const ASSETS_GLOB = `app/src/assets/*.*`
// Clean DIST directory
export function clean () {
return del([DIST_DIR])
}
// JS Task
export function scripts () {
return src(JS_GLOB, {
base: SRC_DIR
})
.pipe(babel({
compact: true
}))
.pipe(dest(DIST_DIR))
}
export function html () {
return src(HTML_GLOB, {
base: SRC_DIR
})
.pipe(dest(DIST_DIR))
}
export function styles () {
return src(CSS_GLOB, {
base: SRC_DIR
})
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(autoprefixer())
.pipe(dest(DIST_DIR))
}
export function assets () {
return src(ASSETS_GLOB, {
base: SRC_DIR
})
.pipe(image())
.pipe(dest(DIST_DIR))
}
export function watch () {
watchSrc(JS_GLOB, scripts)
watchSrc(HTML_GLOB, html)
watchSrc(CSS_GLOB, styles)
watchSrc(ASSETS_GLOB, assets)
}
const mainTasks = parallel(scripts, html, styles, assets)
export const build = series(clean, mainTasks)
export const dev = series(clean, mainTasks, watch)
// Set default task
export default build