Last active
July 6, 2023 03:53
-
-
Save dbarjs/c9d8d4b4e19bffcf3aa3dc041d2993f6 to your computer and use it in GitHub Desktop.
Fix for absolute paths on builded tsconfig.json on Nuxt 3.6.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { relative, resolve } from 'node:path'; | |
export default defineNuxtConfig({ | |
hooks: { | |
'prepare:types': ({ tsConfig }) => { | |
if (!tsConfig?.compilerOptions?.paths) { | |
return; | |
} | |
const rootDir = process.cwd(); | |
const nuxtDirectory = resolve(rootDir, '.nuxt'); | |
const baseUrl = relative(nuxtDirectory, rootDir); | |
const relativePaths = Object.entries<string[]>( | |
tsConfig.compilerOptions.paths, | |
).reduce<Record<string, string[]>>((paths, [pattern, locations]) => { | |
if (Array.isArray(locations)) { | |
paths[pattern] = locations.map((location) => { | |
return relative(rootDir, location); | |
}); | |
} | |
return paths; | |
}, {}); | |
tsConfig.compilerOptions.baseUrl = baseUrl; | |
tsConfig.compilerOptions.paths = relativePaths; | |
}, | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by nuxi | |
{ | |
"compilerOptions": { | |
"forceConsistentCasingInFileNames": true, | |
"jsx": "preserve", | |
"target": "ESNext", | |
"module": "ESNext", | |
"moduleResolution": "Node", | |
"skipLibCheck": true, | |
"strict": true, | |
"allowJs": true, | |
"baseUrl": "..", | |
"noEmit": true, | |
"resolveJsonModule": true, | |
"allowSyntheticDefaultImports": true, | |
"types": [ | |
"node" | |
], | |
"paths": { | |
"~": [ | |
"" | |
], | |
"~/*": [ | |
"*" | |
], | |
"@": [ | |
"" | |
], | |
"@/*": [ | |
"*" | |
], | |
"~~": [ | |
"" | |
], | |
"~~/*": [ | |
"*" | |
], | |
"@@": [ | |
"" | |
], | |
"@@/*": [ | |
"*" | |
], | |
"assets": [ | |
"assets" | |
], | |
"public": [ | |
"public" | |
], | |
"public/*": [ | |
"public/*" | |
], | |
"#app": [ | |
"../../node_modules/nuxt/dist/app" | |
], | |
"#app/*": [ | |
"../../node_modules/nuxt/dist/app/*" | |
], | |
"vue-demi": [ | |
"../../node_modules/nuxt/dist/app/compat/vue-demi" | |
], | |
"#vue-router": [ | |
".nuxt/vue-router" | |
], | |
"#imports": [ | |
".nuxt/imports" | |
], | |
"#build": [ | |
".nuxt" | |
], | |
"#build/*": [ | |
".nuxt/*" | |
], | |
"#components": [ | |
"/home/dbarjs/_dev/flux-jobboard/apps/job-preferences/.nuxt/components" | |
] | |
} | |
}, | |
"include": [ | |
"./nuxt.d.ts", | |
"../**/*" | |
], | |
"exclude": [ | |
"../dist", | |
"../.output" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by nuxi | |
{ | |
"compilerOptions": { | |
"forceConsistentCasingInFileNames": true, | |
"jsx": "preserve", | |
"target": "ESNext", | |
"module": "ESNext", | |
"moduleResolution": "Node", | |
"skipLibCheck": true, | |
"strict": true, | |
"allowJs": true, | |
"baseUrl": "/home/app/packages/web", | |
"noEmit": true, | |
"resolveJsonModule": true, | |
"allowSyntheticDefaultImports": true, | |
"types": [ | |
"node" | |
], | |
"paths": { | |
"~": [ | |
"/home/app/packages/web" | |
], | |
"~/*": [ | |
"/home/app/packages/web/*" | |
], | |
"@": [ | |
"/home/app/packages/web" | |
], | |
"@/*": [ | |
"/home/app/packages/web/*" | |
], | |
"~~": [ | |
"/home/app/packages/web" | |
], | |
"~~/*": [ | |
"/home/app/packages/web/*" | |
], | |
"@@": [ | |
"/home/app/packages/web" | |
], | |
"@@/*": [ | |
"/home/app/packages/web/*" | |
], | |
"assets": [ | |
"/home/app/packages/web/assets" | |
], | |
"public": [ | |
"/home/app/packages/web/public" | |
], | |
"public/*": [ | |
"/home/app/packages/web/public/*" | |
], | |
"#app": [ | |
"/home/app/node_modules/nuxt/dist/app" | |
], | |
"#app/*": [ | |
"/home/app/node_modules/nuxt/dist/app/*" | |
], | |
"vue-demi": [ | |
"/home/app/node_modules/nuxt/dist/app/compat/vue-demi" | |
], | |
"#vue-router": [ | |
"/home/app/packages/web/.nuxt/vue-router" | |
], | |
"#imports": [ | |
"/home/app/packages/web/.nuxt/imports" | |
], | |
"#build": [ | |
"/home/app/packages/web/.nuxt" | |
], | |
"#build/*": [ | |
"/home/app/packages/web/.nuxt/*" | |
], | |
"#components": [ | |
"/home/app/packages/web/.nuxt/components" | |
] | |
} | |
}, | |
"include": [ | |
"./nuxt.d.ts", | |
"../**/*" | |
], | |
"exclude": [ | |
"../dist", | |
"../.output" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related issue: nuxt/nuxt#21827