feat: add tsConfigPath option

This commit is contained in:
samk-dev 2024-04-06 14:00:15 +02:00
parent c20746a2b4
commit f1a7097464
2 changed files with 7 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import { resolveImport } from '@/src/utils/resolve-import'
export const DEFAULT_STYLE = 'default' export const DEFAULT_STYLE = 'default'
export const DEFAULT_COMPONENTS = '@/components' export const DEFAULT_COMPONENTS = '@/components'
export const DEFAULT_UTILS = '@/lib/utils' export const DEFAULT_UTILS = '@/lib/utils'
export const DEFAULT_TYPESCRIPT_CONFIG = './tsconfig.json'
export const DEFAULT_TAILWIND_CONFIG = 'tailwind.config.js' export const DEFAULT_TAILWIND_CONFIG = 'tailwind.config.js'
export const DEFAULT_TAILWIND_BASE_COLOR = 'slate' export const DEFAULT_TAILWIND_BASE_COLOR = 'slate'
@ -32,9 +33,7 @@ export const rawConfigSchema = z
prefix: z.string().optional(), prefix: z.string().optional(),
}), }),
framework: z.string().default('Vite'), framework: z.string().default('Vite'),
nuxt: z.object({ tsConfigPath: z.string().default('./tsconfig.json'),
buildDir: z.string().default('.nuxt'),
}).optional(),
aliases: z.object({ aliases: z.object({
components: z.string(), components: z.string(),
utils: z.string(), utils: z.string(),
@ -71,7 +70,7 @@ export async function resolveConfigPaths(cwd: string, config: RawConfig) {
let tsConfig: ConfigLoaderResult | undefined let tsConfig: ConfigLoaderResult | undefined
let tsConfigPath = path.resolve( let tsConfigPath = path.resolve(
cwd, cwd,
config.framework === 'nuxt' ? `${config.nuxt?.buildDir}/tsconfig.json` : './tsconfig.json', config.tsConfigPath,
) )
if (config.typescript) { if (config.typescript) {

View File

@ -19,6 +19,7 @@ it('get raw config', async () => {
baseColor: 'neutral', baseColor: 'neutral',
cssVariables: false, cssVariables: false,
}, },
tsConfigPath: './tsconfig.json',
aliases: { aliases: {
components: '@/components', components: '@/components',
utils: '@/lib/utils', utils: '@/lib/utils',
@ -55,6 +56,7 @@ it('get config', async () => {
utils: '@/lib/utils', utils: '@/lib/utils',
}, },
framework: 'Vite', framework: 'Vite',
tsConfigPath: './tsconfig.json',
resolvedPaths: { resolvedPaths: {
tailwindConfig: path.resolve( tailwindConfig: path.resolve(
__dirname, __dirname,
@ -102,6 +104,7 @@ it('get config', async () => {
utils: '~/lib/utils', utils: '~/lib/utils',
}, },
framework: 'Vite', framework: 'Vite',
tsConfigPath: './tsconfig.json',
resolvedPaths: { resolvedPaths: {
tailwindConfig: path.resolve( tailwindConfig: path.resolve(
__dirname, __dirname,
@ -148,6 +151,7 @@ it('get config', async () => {
utils: '@/lib/utils', utils: '@/lib/utils',
}, },
framework: 'Vite', framework: 'Vite',
tsConfigPath: './tsconfig.json',
resolvedPaths: { resolvedPaths: {
tailwindConfig: path.resolve( tailwindConfig: path.resolve(
__dirname, __dirname,