-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
77 lines (62 loc) · 1.82 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
const path = require('path')
const fs = require('fs-extra')
const ProductionLine = require('productionline-web')
const Chassis = require('@chassis/core')
class CustomProductionLine extends ProductionLine {
constructor (cfg) {
super(cfg)
}
buildCSS (minify = true, cb) {
let tasks = new this.TaskRunner()
this.walk(this.paths.css).forEach(filepath => {
tasks.add(`Process ${this.localDirectory(filepath)}`, next => {
let chassis = new Chassis({
minify,
sourceMap: minify,
sourceMapPath: path.dirname(this.outputDirectory(filepath)),
theme: path.resolve(`${this.SOURCE}/css/main.theme`)
})
chassis.process(filepath, (err, processed) => {
if (err) {
throw err
}
if (processed.sourceMap) {
this.writeFileSync(`${this.outputDirectory(filepath)}.map`, processed.sourceMap)
}
this.writeFile(this.outputDirectory(filepath), processed.css, next)
})
})
})
tasks.on('complete', cb)
tasks.run()
}
make (dev = false) {
this.clean()
this.copyAssets()
this.buildHTML()
this.buildJavaScript()
this.addTask('Build CSS', next => this.buildCSS(!dev, next))
}
}
const builder = new CustomProductionLine({
header: `Copyright (c) ${new Date().getFullYear()} Ecor Ventures LLC.\nVersion ${this.version} built on ${new Date().toString()}`,
commands: {
'--prod' (cmd) {
builder.make()
},
'--dev' (cmd) {
builder.make(true)
builder.watch((action, filepath) => {
if (action === 'create' || action === 'update') {
builder.make(true)
builder.run()
}
})
}
}
})
builder.assets = path.resolve('./src/assets')
builder.paths = {
css: path.join(builder.SOURCE, '/**/*.css')
}
builder.run()