fite/index.js

42 lines
810 B
JavaScript
Raw Normal View History

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-10 15:05:30 +08:00
import createServer from './lib/dev.js'
import compile from './lib/prod.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-10-10 15:05:30 +08:00
const SOURCE_DIR = join(WORK_SPACE, 'src')
2022-10-09 19:19:21 +08:00
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) {
2022-10-10 15:05:30 +08:00
createServer(SOURCE_DIR, conf.default)
2022-09-28 18:56:47 +08:00
})
.catch(err => {
console.log('Import Error:', err)
})
break
case 'build':
2022-10-09 19:19:21 +08:00
import(CONFIG_FILE)
.then(function (conf) {
2022-10-10 15:05:30 +08:00
compile(SOURCE_DIR, conf.default)
2022-10-09 19:19:21 +08:00
})
.catch(err => {
console.log('Import Error:', err)
})
2022-09-28 18:56:47 +08:00
break
}