Skip to content

Commit

Permalink
chore: resolve server options
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Aug 14, 2024
1 parent 56c02ce commit 415974c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions packages/core/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ const COMMANDS = {
START: 'start',
BUILD: 'build',
WATCH: 'watch',
PREVIEW: 'preview'
PREVIEW: 'preview',
CLEAN: 'clean'
} as const;

/**
Expand Down Expand Up @@ -223,22 +224,25 @@ async function handleLazyCompilation(
command: keyof typeof COMMANDS
) {
const commandHandlers = {
[COMMANDS.START]: async (cfg: any) => {
[COMMANDS.START]: async (cfg: ResolvedUserConfig) => {
if (
cfg.compilation.lazyCompilation &&
typeof cfg.server?.host === 'string'
) {
await setLazyCompilationDefine(cfg);
}
},
[COMMANDS.WATCH]: async (cfg: any) => {
[COMMANDS.WATCH]: async (cfg: ResolvedUserConfig) => {
if (cfg.compilation?.lazyCompilation) {
await setLazyCompilationDefine(cfg);
}
}
};

await commandHandlers[command]?.(config);
const handler = commandHandlers[command as keyof typeof commandHandlers];
if (handler) {
await handler(config);
}
}

/**
Expand Down Expand Up @@ -554,7 +558,7 @@ export const DEFAULT_DEV_SERVER_OPTIONS: NormalizedServerConfig = {
protocol: 'http',
hostname: { name: 'localhost', host: undefined },
host: true,
proxy: {},
proxy: undefined,
hmr: DEFAULT_HMR_OPTIONS,
middlewareMode: false,
open: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class Server implements ImplDevServer {
hostname
};

const isProxy = Object.keys(options.proxy).length;
const isProxy = options.proxy;
if (https) {
if (isProxy) {
this.server = httpsServer.createServer(https, this._app.callback());
Expand Down

0 comments on commit 415974c

Please sign in to comment.