forked from 409H/landing
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.js
104 lines (81 loc) · 2.44 KB
/
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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const fs = require('fs')
const fsExtra = require('fs-extra')
const rmRf = require('rimraf')
const Streams = require('mississippi')
const bind = require('ap').partial
const async = require('./async')
const Browserify = require('browserify')
const watchify = require('watchify')
const sassStream = require('sass-css-stream')
start(function(err){
if (err) throw err
console.log('end')
})
function start(cb){
async.series({
clean,
build,
}, cb)
}
function clean(cb){
fsExtra.remove('./dist/', cb)
}
function build(cb){
async.parallel({
buildJs,
buildCss,
buildStatic,
}, cb)
}
function buildJs(cb) {
var browserify = Browserify({
entries: ['./src/js/index.js'],
cache: {},
packageCache: {},
// plugin: [watchify],
})
browserify.on('update', bundle)
async.series({
buildJsPrep: bind(fsExtra.mkdirs, './dist/js'),
buildJsStart: start,
}, cb)
function start(cb){
var firstBundle = bundle()
Streams.finished(firstBundle, cb)
}
function bundle() {
console.log('bundle')
return Streams.pipeline(
browserify.bundle(),
fs.createWriteStream('./dist/js/bundle.js')
)
}
}
function buildCss(cb) {
async.series({
buildCssPrep: bind(fsExtra.mkdirs, './dist/css'),
buildCssStart: start,
}, cb)
function start(cb) {
var pipeline = Streams.pipeline(
fs.createReadStream( './src/css/index.scss' ),
sassStream( './src/css/index.scss' ),
fs.createWriteStream( './dist/css/bundle.css' )
)
Streams.finished(pipeline, cb)
}
}
function buildStatic(cb) {
async.parallel({
imgs: bind(fsExtra.copy, './src/img/', './dist/img/'),
faviconAndroid: bind(fsExtra.copy, './src/manifest.json', './dist/manifest.json'),
faviconIE: bind(fsExtra.copy, './src/browserconfig.xml', './dist/browserconfig.xml'),
fonts: bind(fsExtra.copy, './src/fonts/', './dist/fonts/'),
index: bind(fsExtra.copy, './src/index.html', './dist/index.html'),
privacy: bind(fsExtra.copy, './src/privacy.html', './dist/privacy.html'),
terms: bind(fsExtra.copy, './src/terms.html', './dist/terms.html'),
phishing: bind(fsExtra.copy, './src/phishing.html', './dist/phishing.html'),
attributions: bind(fsExtra.copy, './src/attributions.html', './dist/attributions.html'),
goog: bind(fsExtra.copy, './src/google3bfcd95a7b5008a9.html', './dist/google3bfcd95a7b5008a9.html'),
}, cb)
}