-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
70 lines (57 loc) · 1.74 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import gulp from 'gulp'
const { dest, parallel, series, src, watch } = gulp
import postcss from 'gulp-postcss'
import postcssImport from 'postcss-import'
import concat from 'gulp-concat'
import bs from 'browser-sync'
import autoprefixer from 'autoprefixer'
import rename from 'gulp-rename'
import { deleteSync } from 'del'
export const serve = (() => {
const browserSync = bs.create()
let postCssPlugins = [postcssImport]
async function init() {
browserSync.init({ server: 'site' })
}
async function htmlReload() {
watch(['samples/*.html'], { ignoreInitial: false }, async function htmlReloadCb() {
src(['samples/*.html', '!samples/index.html'])
.pipe(dest('site/dark'))
.pipe(dest('site/light'))
// prettier-ignore
src('samples/index.html')
.pipe(dest('site'))
browserSync.reload()
})
}
async function cssInject() {
watch('src/*.css', { ignoreInitial: false }, async function cssInjectCb() {
src('src/theme-light.css')
.pipe(concat('fox.css'))
.pipe(postcss(postCssPlugins))
.pipe(dest('site/light/styles'))
.pipe(browserSync.stream())
src('src/theme-dark.css')
.pipe(concat('fox.css'))
.pipe(postcss(postCssPlugins))
.pipe(dest('site/dark/styles'))
.pipe(browserSync.stream())
})
}
return series(init, parallel(htmlReload, cssInject))
})()
export async function build() {
let postCssPlugins = [postcssImport, autoprefixer]
deleteSync(['dist/*', '!dist'])
src('site/light/styles/fox.css')
.pipe(postcss(postCssPlugins))
.pipe(rename('fox-light.min.css'))
.pipe(dest('dist'))
.pipe(rename('fox-min.css'))
.pipe(dest('dist'))
src('site/dark/styles/fox.css')
.pipe(postcss(postCssPlugins))
.pipe(rename('fox-dark.min.css'))
.pipe(dest('dist'))
}
export default serve