-
Notifications
You must be signed in to change notification settings - Fork 0
/
emk.js
71 lines (61 loc) · 1.27 KB
/
emk.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
const fs = require('fs');
const files = (pd_src, r_ext=/$/) => fs.readdirSync(pd_src)
.filter(s => r_ext.test(s))
.reduce((h_dir, s_file) => ({
...h_dir,
[s_file.replace(r_ext, '')]: pd_src+'/'+s_file,
}), {});
let h_layouts = files('src/webapp/_layouts', /\.pug$/);
let h_scripts = files('src/webapp/_scripts', /\.js$/);
let h_styles = files('src/webapp/_styles', /\.less$/);
module.exports = {
defs: {
layout: Object.keys(h_layouts),
script: Object.keys(h_scripts),
style: Object.keys(h_styles),
},
tasks: {
all: 'build/**',
},
outputs: {
build: {
main: {
'phuzzy.js': () => ({
copy: 'src/main/phuzzy.js',
}),
},
webapp: {
_layouts: {
':layout.html': ({layout:s_layout}) => ({
deps: [
h_layouts[s_layout],
],
run: /* syntax: bash */ `
npx pug --pretty < $1 > $@
`,
}),
},
_scripts: {
':script.js': ({script:s_script}) => ({
deps: [
h_scripts[s_script],
],
run: /* syntax: bash */ `
npx browserify $1 --debug > $@
`,
}),
},
_styles: {
':style.css': ({style:s_style}) => ({
deps: [
h_styles[s_style],
],
run: /* syntax: bash */ `
npx less - < $1 > $@
`,
}),
},
},
},
},
};