-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbulbofile.js
72 lines (60 loc) · 1.63 KB
/
bulbofile.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
const bulbo = require('bulbo')
const asset = bulbo.asset
const bundler = require('bundle-through')
const frontMatter = require('gulp-front-matter')
const layout1 = require('layout1')
const postcss = require('gulp-postcss')
const atImport = require('postcss-import')
const rename = require('gulp-rename')
const path = require('path')
const config = { lang: 'en' }
const presets = require('./src/debug/ls-switch/presets')
const basepath = process.env.BASEPATH || ''
const SRC = 'src'
const IS_DEV = process.env.NODE_ENV !== 'production'
const templateData = { config, basepath, IS_DEV, presets }
const paths = {
js: {
entry: `${SRC}/*/index.js`,
all: `${SRC}/**/*.js`
},
css: {
src: [`${SRC}/*/index.css`, `${SRC}/common/cell.css`],
all: `${SRC}/**/*.css`
},
html: {
page: `${SRC}/*/index.html`,
data: `${SRC}/*/data/**/*.html`
},
layout: {
default: `${SRC}/common/layout.njk`
},
vendor: `${SRC}/vendor/**/*.*`,
img: `${SRC}/**/*.{svg,png}`
}
// js
asset(paths.js.entry)
.assetOptions({ read: false })
.watch(paths.js.entry, paths.js.all)
.pipe(bundler({ transform: 'babelify' }))
// html
asset(paths.html.page)
.watch(paths.html.page, paths.layout.default)
.pipe(frontMatter())
.pipe(rename(p => {
p.basename = path.basename(p.dirname)
p.dirname = path.dirname(p.dirname)
}))
.pipe(layout1.nunjucks(paths.layout.default, { data: templateData }))
// css
asset(paths.css.src)
.watch(paths.css.src, paths.css.all)
.pipe(postcss([atImport()]))
// data
asset(paths.html.data)
// images
asset(paths.img)
// vendor things
asset(paths.vendor)
bulbo.base(SRC)
bulbo.debugPagePath('__pairs__')