提交 fe07b316 编写于 作者: fxy060608's avatar fxy060608

feat(cli): cli mode options to common (#3000)

上级 1f67d1c8
......@@ -63,7 +63,7 @@ function initBuildOptions(
root: process.env.VITE_ROOT_DIR,
logLevel: options.logLevel,
clearScreen: options.clearScreen,
mode: process.env.NODE_ENV,
mode: options.mode,
build,
}
}
......
......@@ -20,6 +20,8 @@ export interface CliOptions {
f?: string
logLevel?: LogLevel
l?: LogLevel
m?: string
mode?: string
clearScreen?: boolean
autoHost?: string
autoPort?: number
......@@ -37,6 +39,7 @@ cli
.option('--clearScreen', `[boolean] allow/disable clear screen when logging`)
.option('-d, --debug [feat]', `[string | boolean] show debug logs`)
.option('-f, --filter <filter>', `[string] filter debug logs`)
.option('-m, --mode <mode>', `[string] set env mode`)
.option('--autoHost [autoHost]', `[string] specify automator hostname`)
.option('--autoPort [autoPort]', `[number] specify automator port`)
.option('--subpackage [subpackage]', `[string] specify subpackage to build`)
......@@ -81,7 +84,6 @@ cli
default: true,
}
)
.option('-m, --mode <mode>', `[string] set env mode`)
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
.action(runBuild)
......
......@@ -17,6 +17,7 @@ export async function createServer(options: CliOptions & ServerOptions) {
const server = await createViteServer(
addConfigFile({
root: process.env.VITE_ROOT_DIR,
mode: options.mode,
logLevel: options.logLevel,
clearScreen: options.clearScreen,
server: cleanOptions(options) as ServerOptions,
......@@ -48,6 +49,7 @@ export async function createSSRServer(
const vite = await createViteServer(
addConfigFile({
root: process.env.VITE_ROOT_DIR,
mode: options.mode,
logLevel: options.logLevel,
clearScreen: options.clearScreen,
server: {
......
......@@ -174,6 +174,8 @@ export function cleanOptions(options: CliOptions) {
delete ret.logLevel
delete ret.l
delete ret.clearScreen
delete ret.m
delete ret.mode
delete ret.autoHost
delete ret.autoPort
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册