feat(runner): update build-all command

This commit is contained in:
Haoyu Xu
2023-01-20 14:51:24 -05:00
parent 75d42ff271
commit 3791a77852
6 changed files with 146 additions and 155 deletions

48
libs/vite.js Normal file
View File

@@ -0,0 +1,48 @@
import path from 'path'
import { createServer, build } from 'vite'
export default class Vite {
#config
#rootDir
#operatorName
constructor(config, operatorName, rootDir) {
this.#config = config
this.#operatorName = operatorName
this.#rootDir = rootDir
}
dev() {
; (async () => {
const server = await createServer(this.#viteConfig)
await server.listen()
server.printUrls()
})()
}
async build() {
await build(this.#viteConfig)
}
get #viteConfig() {
return {
base: "",
publicDir: path.resolve(this.#rootDir, this.#config.folder.release, this.#operatorName),
root: path.resolve(this.#rootDir),
resolve: {
alias: {
'@': path.resolve(this.#rootDir, './src'),
'!': path.resolve(this.#rootDir, this.#config.folder.operator, this.#operatorName),
'#': path.resolve(this.#config.basedir, this.#config.folder.operator, this.#operatorName, `${this.#config.operators[this.#operatorName].filename}.json`),
},
},
build: {
outDir: path.resolve(this.#rootDir, this.#config.folder.release, this.#operatorName),
emptyOutDir: false,
chunkSizeWarningLimit: 10000,
},
}
}
}