feat(runner): update build-all command
This commit is contained in:
@@ -9,28 +9,22 @@ export default class EnvGenerator {
|
||||
this.#assets = assets
|
||||
}
|
||||
|
||||
async generate() {
|
||||
return await this.#promise()
|
||||
}
|
||||
|
||||
#promise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve([
|
||||
`VITE_TITLE="${this.#operatorConfig.title}"`,
|
||||
`VITE_FILENAME=${this.#operatorConfig.filename.replace('#', '%23')}`,
|
||||
`VITE_LOGO_FILENAME=${this.#operatorConfig.logo}`,
|
||||
`VITE_FALLBACK_FILENAME=${this.#operatorConfig.fallback_name.replace('#', '%23')}`,
|
||||
`VITE_VIEWPORT_LEFT=${this.#operatorConfig.viewport_left}`,
|
||||
`VITE_VIEWPORT_RIGHT=${this.#operatorConfig.viewport_right}`,
|
||||
`VITE_VIEWPORT_TOP=${this.#operatorConfig.viewport_top}`,
|
||||
`VITE_VIEWPORT_BOTTOM=${this.#operatorConfig.viewport_bottom}`,
|
||||
`VITE_INVERT_FILTER=${this.#operatorConfig.invert_filter}`,
|
||||
`VITE_IMAGE_WIDTH=2048`,
|
||||
`VITE_IMAGE_HEIGHT=2048`,
|
||||
`VITE_BACKGROUND_FILES=${JSON.stringify(this.#assets.backgrounds)}`,
|
||||
`VITE_BACKGROUND_FOLDER=${this.#config.folder.background}`,
|
||||
].join('\n'))
|
||||
})
|
||||
generate() {
|
||||
return [
|
||||
`VITE_TITLE="${this.#operatorConfig.title}"`,
|
||||
`VITE_FILENAME=${this.#operatorConfig.filename.replace('#', '%23')}`,
|
||||
`VITE_LOGO_FILENAME=${this.#operatorConfig.logo}`,
|
||||
`VITE_FALLBACK_FILENAME=${this.#operatorConfig.fallback_name.replace('#', '%23')}`,
|
||||
`VITE_VIEWPORT_LEFT=${this.#operatorConfig.viewport_left}`,
|
||||
`VITE_VIEWPORT_RIGHT=${this.#operatorConfig.viewport_right}`,
|
||||
`VITE_VIEWPORT_TOP=${this.#operatorConfig.viewport_top}`,
|
||||
`VITE_VIEWPORT_BOTTOM=${this.#operatorConfig.viewport_bottom}`,
|
||||
`VITE_INVERT_FILTER=${this.#operatorConfig.invert_filter}`,
|
||||
`VITE_IMAGE_WIDTH=2048`,
|
||||
`VITE_IMAGE_HEIGHT=2048`,
|
||||
`VITE_BACKGROUND_FILES=${JSON.stringify(this.#assets.backgrounds)}`,
|
||||
`VITE_BACKGROUND_FOLDER=${this.#config.folder.background}`,
|
||||
].join('\n')
|
||||
}
|
||||
|
||||
}
|
||||
26
libs/exec.js
26
libs/exec.js
@@ -1,26 +0,0 @@
|
||||
import { execSync } from 'child_process'
|
||||
import { createServer, build } from 'vite'
|
||||
|
||||
export function buildAll(config) {
|
||||
for (const [key, _] of Object.entries(config.operators)) {
|
||||
if (key.startsWith('_')) break;
|
||||
console.log(execSync(`node runner.js build ${key}`).toString());
|
||||
}
|
||||
}
|
||||
|
||||
export function runDev(rootDir) {
|
||||
; (async () => {
|
||||
const server = await createServer({
|
||||
root: rootDir,
|
||||
})
|
||||
await server.listen()
|
||||
|
||||
server.printUrls()
|
||||
})()
|
||||
}
|
||||
|
||||
export async function runBuild(rootDir) {
|
||||
await build({
|
||||
root: rootDir,
|
||||
})
|
||||
}
|
||||
48
libs/vite.js
Normal file
48
libs/vite.js
Normal 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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user