forked from oct16/TimeCat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
38 lines (34 loc) · 1.02 KB
/
dev.js
File metadata and controls
38 lines (34 loc) · 1.02 KB
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
const execa = require('execa')
const path = require('path')
const browserSync = require('browser-sync')
const env = 'development'
const args = require('minimist')(process.argv.slice(2))
const target = 'timecat'
const formats = args.formats || args.f
const resolveRoot = file => path.resolve('.', file)
const resolvePackage = name => path.resolve(resolveRoot('packages'), target, name)
run()
async function run() {
execa(
'rollup',
['-wc', '--environment', [`NODE_ENV:${env}`, `TARGET:${target}`, `FORMATS:${formats || 'global|esm|cjs'}`]],
{
stdio: 'inherit'
}
)
await new Promise(r => setTimeout(() => r(), 2000))
browserSync({
codeSync: false,
server: [resolvePackage('dist'), resolveRoot('examples')],
port: 4321,
notify: false,
open: false,
cors: true,
rewriteRules: [
{
match: '//cdn.jsdelivr.net/npm/timecatjs',
replace: './timecat.global.js'
}
]
})
}