Skip to content

Commit

Permalink
docs: update installation for vite (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxliuli authored Jan 8, 2025
1 parent db4f160 commit 8deb4d0
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions sites/docs/src/content/installation/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ Use the Svelte CLI to add Tailwind CSS to your project.

<PMInstall />

### Setup path aliases
### Edit tsconfig.json file

Update your path aliases in your `tsconfig.json` and `vite.config.ts`.
The current version of Vite splits TypeScript configuration into three files, two of which need to be edited.
Add the `baseUrl` and `paths` properties to the `compilerOptions` section of the `tsconfig.json` and
`tsconfig.app.json` files:

```json title="tsconfig.json" {3-7}
{
Expand All @@ -38,6 +40,35 @@ Update your path aliases in your `tsconfig.json` and `vite.config.ts`.
}
```

### Edit tsconfig.app.json file

Add the following code to the `tsconfig.app.json` file to resolve paths, for your IDE:

```ts title="tsconfig.app.json" {11-17}
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"$lib": ["./src/lib"],
"$lib/*": ["./src/lib/*"]
}
}
}
```

### Update vite.config.ts

Add the following code to the vite.config.ts so your app can resolve paths without error:

```js title="vite.config.ts" {1, 5-9}
import path from "path";

Expand Down

0 comments on commit 8deb4d0

Please sign in to comment.