Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
terkelg
GitHub Repository: terkelg/ramme
Path: blob/master/gulpfile.babel.js
106 views
1
import {
2
src,
3
dest,
4
watch as watchSrc,
5
parallel,
6
series
7
} from 'gulp'
8
import babel from 'gulp-babel'
9
import del from 'del'
10
import autoprefixer from 'gulp-autoprefixer'
11
import image from 'gulp-image'
12
import sass from 'gulp-sass'
13
14
// Directories
15
const SRC_DIR = 'app/src'
16
const DIST_DIR = 'app/dist'
17
18
// Source files
19
const JS_GLOB = `${SRC_DIR}/**/*.js`
20
const CSS_GLOB = `${SRC_DIR}/**/*.scss`
21
const HTML_GLOB = `${SRC_DIR}/**/*.html`
22
const ASSETS_GLOB = `app/src/assets/*.*`
23
24
// Clean DIST directory
25
export function clean () {
26
return del([DIST_DIR])
27
}
28
29
// JS Task
30
export function scripts () {
31
return src(JS_GLOB, {
32
base: SRC_DIR
33
})
34
.pipe(babel({
35
compact: true
36
}))
37
.pipe(dest(DIST_DIR))
38
}
39
40
export function html () {
41
return src(HTML_GLOB, {
42
base: SRC_DIR
43
})
44
.pipe(dest(DIST_DIR))
45
}
46
47
export function styles () {
48
return src(CSS_GLOB, {
49
base: SRC_DIR
50
})
51
.pipe(sass({
52
outputStyle: 'compressed'
53
}).on('error', sass.logError))
54
.pipe(autoprefixer())
55
.pipe(dest(DIST_DIR))
56
}
57
58
export function assets () {
59
return src(ASSETS_GLOB, {
60
base: SRC_DIR
61
})
62
.pipe(image())
63
.pipe(dest(DIST_DIR))
64
}
65
66
export function watch () {
67
watchSrc(JS_GLOB, scripts)
68
watchSrc(HTML_GLOB, html)
69
watchSrc(CSS_GLOB, styles)
70
watchSrc(ASSETS_GLOB, assets)
71
}
72
73
const mainTasks = parallel(scripts, html, styles, assets)
74
export const build = series(clean, mainTasks)
75
export const dev = series(clean, mainTasks, watch)
76
77
// Set default task
78
export default build
79
80