diff --git a/packages/cli/test/fixtures/config-jsconfig/components.json b/packages/cli/test/fixtures/config-jsconfig/components.json new file mode 100644 index 000000000..804221b5a --- /dev/null +++ b/packages/cli/test/fixtures/config-jsconfig/components.json @@ -0,0 +1,12 @@ +{ + "style": "new-york", + "tailwind": { + "config": "tailwind.config.js", + "css": "src/app.pcss", + "baseColor": "zinc" + }, + "aliases": { + "utils": "$lib/utils", + "components": "$lib/components" + } +} diff --git a/packages/cli/test/fixtures/config-jsconfig/jsconfig.json b/packages/cli/test/fixtures/config-jsconfig/jsconfig.json new file mode 100644 index 000000000..456bb65aa --- /dev/null +++ b/packages/cli/test/fixtures/config-jsconfig/jsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "moduleResolution": "bundler", + "paths": { + "$lib": ["./src/lib"], + "$lib/*": ["./src/lib/*"] + } + } +} diff --git a/packages/cli/test/fixtures/config-jsconfig/package.json b/packages/cli/test/fixtures/config-jsconfig/package.json new file mode 100644 index 000000000..29857aab7 --- /dev/null +++ b/packages/cli/test/fixtures/config-jsconfig/package.json @@ -0,0 +1,14 @@ +{ + "name": "test-cli-config-full", + "version": "0.0.0", + "private": true, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.0", + "svelte": "^4.2.7", + "svelte-check": "^3.6.0", + "tslib": "^2.4.1", + "typescript": "^5.0.0", + "vite": "^5.0.3" + }, + "type": "module" +} diff --git a/packages/cli/test/utils/get-config.spec.ts b/packages/cli/test/utils/get-config.spec.ts index 45ac91dfb..99d591f44 100644 --- a/packages/cli/test/utils/get-config.spec.ts +++ b/packages/cli/test/utils/get-config.spec.ts @@ -165,4 +165,41 @@ describe("getConfig", () => { } }); }); + + it("handles cases where the project uses jsconfig.json", async () => { + expect(await getConf("config-jsconfig")).toEqual({ + style: "new-york", + tailwind: { + config: "tailwind.config.js", + css: "src/app.pcss", + baseColor: "zinc" + }, + aliases: { + utils: "$lib/utils", + components: "$lib/components" + }, + resolvedPaths: { + components: path.resolve( + __dirname, + "../fixtures/config-jsconfig", + "./src/lib/components" + ), + tailwindConfig: path.resolve( + __dirname, + "../fixtures/config-jsconfig", + "./tailwind.config.js" + ), + tailwindCss: path.resolve( + __dirname, + "../fixtures/config-jsconfig", + "./src/app.pcss" + ), + utils: path.resolve( + __dirname, + "../fixtures/config-jsconfig", + "./src/lib/utils" + ) + } + }); + }); });