Skip to content

Commit

Permalink
fix: improve error message upon incorrect setup (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed May 17, 2023
1 parent ef6c7b0 commit 0096e93
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vite-plugin-ssr/node/plugin/plugins/buildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
addOnBeforeLogHook,
removeFileExtention,
unique,
assertPosixPath
assertPosixPath,
assertUsage
} from '../utils'
import { virtualFileIdImportUserCodeServer } from '../../shared/virtual-files/virtualFileImportUserCode'
import { getConfigData } from './importUserCode/v1-design/getConfigData'
Expand All @@ -27,8 +28,10 @@ function buildConfig(): Plugin {
apply: 'build',
enforce: 'post',
async configResolved(config) {
const entries = await getEntries(config)
assert(Object.keys(entries).length > 0)
const input = {
...(await getEntries(config)),
...entries,
...normalizeRollupInput(config.build.rollupOptions.input)
}
config.build.rollupOptions.input = input
Expand All @@ -51,6 +54,10 @@ function buildConfig(): Plugin {
async function getEntries(config: ResolvedConfig): Promise<Record<string, string>> {
const pageFileEntries = await getPageFileEntries(config) // TODO/v1-release: remove
const { pageConfigsData } = await getConfigData(config.root, false, false, (await getConfigVps(config)).extensions)
assertUsage(
Object.keys(pageFileEntries).length !== 0 || pageConfigsData.length !== 0,
'At least one page should be defined, see https://vite-plugin-ssr.com/add'
)
if (viteIsSSR(config)) {
const serverEntries = analyzeServerEntries(pageConfigsData)
const entries = {
Expand Down

0 comments on commit 0096e93

Please sign in to comment.