mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 13:15:12 +00:00
feat(vite): support resolving types from vfs
This commit is contained in:
parent
ed79a1d4bf
commit
01193ea7cf
@ -1,10 +1,12 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
||||
import * as vite from 'vite'
|
||||
import { dirname, join, normalize, resolve } from 'pathe'
|
||||
import type { Nuxt, NuxtBuilder, ViteConfig } from '@nuxt/schema'
|
||||
import { addVitePlugin, isIgnored, logger, resolvePath } from '@nuxt/kit'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import type { Options as VuePluginOptions } from '@vitejs/plugin-vue'
|
||||
import { sanitizeFilePath } from 'mlly'
|
||||
import defu from 'defu'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
import { filename } from 'pathe/utils'
|
||||
import { resolveTSConfig } from 'pkg-types'
|
||||
@ -123,6 +125,16 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
||||
),
|
||||
}
|
||||
|
||||
ctx.config.vue = defu(ctx.config.vue, {
|
||||
script: {
|
||||
fs: {
|
||||
fileExists: file => file in nuxt.vfs || existsSync(file),
|
||||
readFile: file => nuxt.vfs[file] || readFileSync(file, 'utf-8'),
|
||||
realpath: path => path in nuxt.vfs ? path : realpathSync(path),
|
||||
},
|
||||
},
|
||||
} satisfies VuePluginOptions)
|
||||
|
||||
// In build mode we explicitly override any vite options that vite is relying on
|
||||
// to detect whether to inject production or development code (such as HMR code)
|
||||
if (!nuxt.options.dev) {
|
||||
|
Loading…
Reference in New Issue
Block a user