fite/index.js

49 lines
1.0 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* {}
* @author yutent<yutent.io@gmail.com>
* @date 2022/09/28 15:12:45
*/
import fs from 'iofs'
import { join, normalize } from 'path'
import createServer from './lib/dev.js'
import compile from './lib/prod.js'
const WORK_SPACE = process.cwd()
const IS_WINDOWS = process.platform === 'win32'
const CONFIG_FILE = normalize(join(WORK_SPACE, 'vue.live.js'))
const PROTOCOL = IS_WINDOWS ? 'file://' : ''
let args = process.argv.slice(2)
switch (args[0]) {
case 'dev':
import(PROTOCOL + CONFIG_FILE)
.then(function (conf) {
createServer(WORK_SPACE, conf.default)
})
.catch(err => {
console.log(err)
})
break
case 'build':
import(PROTOCOL + CONFIG_FILE)
.then(function (conf) {
let dist = conf.buildDir || 'dist'
if (fs.isdir(dist)) {
fs.rm(dist, true)
}
fs.mkdir(dist)
compile(WORK_SPACE, dist, conf.default)
})
.catch(err => {
console.log(err)
})
break
}
vue3的轻量构建工具。webpack/vite的替代品
JavaScript 100%