mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(vite): ignore and warn if vite config file exists (#21588)
This commit is contained in:
parent
3c88b50bbc
commit
48c2b458a1
@ -21,6 +21,7 @@ import { createViteLogger } from './utils/logger'
|
||||
|
||||
export async function buildClient (ctx: ViteBuildContext) {
|
||||
const clientConfig: ViteConfig = vite.mergeConfig(ctx.config, {
|
||||
configFile: false,
|
||||
base: ctx.nuxt.options.dev
|
||||
? joinURL(ctx.nuxt.options.app.baseURL.replace(/^\.\//, '/') || '/', ctx.nuxt.options.app.buildAssetsDir)
|
||||
: './',
|
||||
|
@ -18,6 +18,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
const helper = ctx.nuxt.options.nitro.imports !== false ? '' : 'globalThis.'
|
||||
const entry = ctx.nuxt.options.ssr ? ctx.entry : await resolvePath(resolve(ctx.nuxt.options.appDir, 'entry-spa'))
|
||||
const serverConfig: ViteConfig = vite.mergeConfig(ctx.config, {
|
||||
configFile: false,
|
||||
base: ctx.nuxt.options.dev
|
||||
? joinURL(ctx.nuxt.options.app.baseURL.replace(/^\.\//, '/') || '/', ctx.nuxt.options.app.buildAssetsDir)
|
||||
: undefined,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import * as vite from 'vite'
|
||||
import { dirname, join, resolve } from 'pathe'
|
||||
import { basename, dirname, join, resolve } from 'pathe'
|
||||
import type { Nuxt, ViteConfig } from '@nuxt/schema'
|
||||
import { addVitePlugin, isIgnored, logger, resolvePath } from '@nuxt/kit'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
@ -8,6 +8,7 @@ import { sanitizeFilePath } from 'mlly'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
import { filename } from 'pathe/utils'
|
||||
import { resolveTSConfig } from 'pkg-types'
|
||||
import { consola } from 'consola'
|
||||
import { buildClient } from './client'
|
||||
import { buildServer } from './server'
|
||||
import virtual from './plugins/virtual'
|
||||
@ -25,6 +26,13 @@ export interface ViteBuildContext {
|
||||
}
|
||||
|
||||
export async function bundle (nuxt: Nuxt) {
|
||||
// https://github.com/vitejs/vite/blob/8fe69524d25d45290179175ba9b9956cbce87a91/packages/vite/src/node/constants.ts#L38
|
||||
const viteConfigPrefix = resolve(nuxt.options.rootDir, 'vite.config')
|
||||
const viteConfigFile = await resolvePath(viteConfigPrefix).catch(() => null)
|
||||
if (viteConfigFile && viteConfigFile !== viteConfigPrefix) {
|
||||
consola.warn(`Using \`${basename(viteConfigFile)}\` is not supported together with Nuxt. Use \`options.vite\` instead. You can read more in \`https://nuxt.com/docs/api/configuration/nuxt-config#vite\`.`)
|
||||
}
|
||||
|
||||
const useAsyncEntry = nuxt.options.experimental.asyncEntry ||
|
||||
(nuxt.options.vite.devBundler === 'vite-node' && nuxt.options.dev)
|
||||
const entry = await resolvePath(resolve(nuxt.options.appDir, useAsyncEntry ? 'entry.async' : 'entry'))
|
||||
|
Loading…
Reference in New Issue
Block a user