@@ -16,7 +16,6 @@ import {
1616 createResolver ,
1717} from '@nuxt/kit' ;
1818import { kebabCase , pascalCase , toMerged } from 'es-toolkit' ;
19- import type { Alias } from 'vite' ;
2019
2120type GenerateArgs = {
2221 moduleConfig : ResolvedConfig ;
@@ -302,7 +301,7 @@ declare module "${nitroClientModule}" {
302301 } from '${ resolver . resolve ( './runtime/server' ) } ';
303302 export const handleFetchPathParams: typeof import('${ resolver . resolve ( './runtime/server' ) } ')['handleFetchPathParams']
304303 export const ensureArray: typeof import('${ resolver . resolve ( './runtime/server' ) } ')['ensureArray']
305- ${ allClientExports . join ( '\n' ) }
304+ ${ allClientExports . join ( '\n ' ) }
306305}` ;
307306 } ,
308307 write : true ,
@@ -406,22 +405,12 @@ const resolveClientConfig = (
406405
407406/** only add alias to app, but not to server. this is different from `nuxt.options.alias` */
408407const addAppAlias = ( nuxt : Nuxt , alias : string , actual : string ) => {
409- nuxt . hook ( 'prepare:types' , ( options ) => {
410- options . tsConfig . compilerOptions ??= { } ;
411- options . tsConfig . compilerOptions . paths ??= { } ;
412- options . tsConfig . compilerOptions . paths [ alias ] = [ actual ] ;
413- options . tsConfig . compilerOptions . paths [ `${ alias } /*` ] = [ `${ actual } /*` ] ;
414- } ) ;
415-
416- nuxt . hook ( 'vite:extendConfig' , ( config ) => {
417- config . resolve ??= { } ;
418-
419- if ( Array . isArray ( config . resolve . alias ) ) {
420- const array = config . resolve . alias as Alias [ ] ;
421- array . push ( { find : alias , replacement : actual } ) ;
422- } else {
423- config . resolve . alias ??= { } ;
424- ( config . resolve . alias as Record < string , string > ) [ alias ] = actual ;
408+ nuxt . options . alias ??= { } ;
409+ nuxt . options . alias [ alias ] = actual ;
410+ nuxt . hook ( 'nitro:config' , ( options ) => {
411+ if ( options . alias ) {
412+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
413+ delete options . alias [ alias ] ;
425414 }
426415 } ) ;
427416} ;
0 commit comments