forked from mattdesl/codevember
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.js
42 lines (38 loc) · 1.08 KB
/
dev.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
const budo = require('budo')
const argv = require('minimist')(process.argv.slice(2))
const path = require('path')
const babelify = require('babelify')
const open = require('opn')
const fs = require('fs')
const simpleHtml = require('simple-html-index')
var entry = argv._[0]
if (!entry) {
entry = 'grid'
}
const transforms = require('./config')
const entryFilename = entry === 'grid'
? path.join(entry, 'index.js')
: (entry + '.js')
const entryFile = path.resolve(__dirname, 'src', entryFilename)
budo(entryFile, {
serve: 'static/' + entry + '.js',
live: true,
verbose: true,
dir: __dirname,
stream: process.stdout,
forceDefaultIndex: true,
defaultIndex: function (opt) {
var html = entry === 'grid' ? 'index.html' : entry + '.html'
if (!fs.existsSync(html)) return simpleHtml(opt)
return fs.createReadStream(html)
},
browserify: {
debug: false,
transform: [
babelify.configure({ presets: ['es2015'] }),
[ 'installify', { save: true } ]
].concat(transforms[entry] || [])
}
}).on('connect', function (ev) {
if (argv.open) open(ev.uri)
})