2022-09-28 18:56:47 +08:00
|
|
|
#!/bin/env node
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {}
|
|
|
|
* @author yutent<yutent.io@gmail.com>
|
|
|
|
* @date 2022/09/28 15:12:45
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { join } from 'path'
|
2022-10-09 19:19:21 +08:00
|
|
|
import { createServer, compile } from './lib/index.js'
|
2022-09-28 18:56:47 +08:00
|
|
|
|
|
|
|
const WORK_SPACE = process.env.INIT_CWD
|
|
|
|
|
2022-10-09 19:19:21 +08:00
|
|
|
const CONFIG_FILE = join(WORK_SPACE, 'vue.live.js')
|
|
|
|
|
2022-09-28 18:56:47 +08:00
|
|
|
let args = process.argv.slice(2)
|
|
|
|
|
|
|
|
switch (args[0]) {
|
|
|
|
case 'dev':
|
2022-10-09 19:19:21 +08:00
|
|
|
import(CONFIG_FILE)
|
2022-09-28 18:56:47 +08:00
|
|
|
.then(function (conf) {
|
|
|
|
// console.log(conf)
|
|
|
|
createServer(WORK_SPACE, conf.default)
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log('Import Error:', err)
|
|
|
|
})
|
|
|
|
break
|
|
|
|
|
|
|
|
case 'build':
|
2022-10-09 19:19:21 +08:00
|
|
|
import(CONFIG_FILE)
|
|
|
|
.then(function (conf) {
|
|
|
|
// console.log(conf)
|
|
|
|
compile(WORK_SPACE, conf.default)
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log('Import Error:', err)
|
|
|
|
})
|
2022-09-28 18:56:47 +08:00
|
|
|
break
|
|
|
|
}
|