-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
32 lines (31 loc) · 921 Bytes
/
build.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
const browserify = require('browserify')
const through = require('through')
const stylus = require('stylus')
const fs = require('fs')
const { PSEUDO_CODE, PSEUDO, INJECT_FLAG, PSEUDO_TARGET } = require('./def')
browserify()
.add('browser.js')
.transform((file) => {
console.log(file)
let data = ''
return through(
function write(buf) {
data += buf
},
function end() {
if (file.endsWith('.styl')) {
data = stylus(data)
.define('PSEUDO', PSEUDO)
.define('PSEUDO_CODE', PSEUDO_CODE)
.define('PSEUDO_TARGET', PSEUDO_TARGET)
.define('INJECT_FLAG', INJECT_FLAG)
.render()
data = 'module.exports = `' + data + '`'
}
this.queue(data)
this.queue(null)
})
})
.transform('uglifyify', { global: true })
.bundle()
.pipe(fs.createWriteStream('dist/browser.min.js'))