-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (44 loc) · 1.35 KB
/
index.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
const cosmiconfig = require('cosmiconfig');
const doServe = require('./lib/serve');
const doBuild = require('./lib/build');
// const stopDir = process.cwd();
const rcLoader = cosmiconfig('penny', { stopDir: process.cwd(), rcExtensions: true });
// function rcCombine(defaults, options) {
// return Object.assign(defaults, options);
// }
/*
TODO: potential options
linting: true, // globally disable eslint + stylelint
caching: true, // whether serve.js should use the renderCache
data: '', // WIP; could also be called 'locals'
stylelint: false,
*/
const options = {
browsers: ['>1%'],
eslint: false,
logLevel: 'warn',
reqSrcExt: { // TODO: pluralize
'.html': '.pug',
'.css': '.scss',
'.js': '.js'
},
};
function serve(srcDir) {
rcLoader
.load(srcDir)
.then((result) => result ? result.config : Object.create(null))
.then((rcOptions) => {
Object.assign(options, rcOptions, { isDev: process.env.NODE_ENV != 'production', isBuild: false});
doServe(srcDir, options);
});
}
function build(srcDir, outDir) {
rcLoader
.load(srcDir)
.then((result) => result ? result.config : Object.create(null))
.then((rcOptions) => {
Object.assign(options, rcOptions, { isDev: process.env.NODE_ENV == 'development', isBuild: true});
doBuild(srcDir, outDir, options);
});
}
module.exports = { serve, build };