Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): do not create server if there is no entry #13612

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ export function scanImports(config: ResolvedConfig): {
}
}

async function computeEntries(config: ResolvedConfig) {
export async function computeEntries(
config: ResolvedConfig,
): Promise<string[]> {
let entries: string[] = []

const explicitEntryPatterns = config.optimizeDeps.entries
Expand Down
8 changes: 8 additions & 0 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
initDepsOptimizer,
initDevSsrDepsOptimizer,
} from '../optimizer'
import { computeEntries } from '../optimizer/scan'
import { bindShortcuts } from '../shortcuts'
import type { BindShortcutsOptions } from '../shortcuts'
import { CLIENT_DIR, DEFAULT_DEV_PORT } from '../constants'
Expand Down Expand Up @@ -340,6 +341,13 @@ export async function _createServer(
): Promise<ViteDevServer> {
const config = await resolveConfig(inlineConfig, 'serve')

const entries = await computeEntries(config)
if (!entries.length) {
config.logger.warn(
`Could not auto-determine entry point from rollupOptions or html files.`,
)
}

const { root, server: serverConfig } = config
const httpsOptions = await resolveHttpsConfig(config.server.https)
const { middlewareMode } = serverConfig
Expand Down