You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/faq/50-aliases.md
+2-36Lines changed: 2 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,40 +2,6 @@
2
2
title: How do I setup a path alias?
3
3
---
4
4
5
-
First, you need to add it to the Vite configuration. In `svelte.config.js`add [`vite.resolve.alias`](https://vitejs.dev/config/#resolve-alias):
5
+
Aliases can be set in `svelte.config.js`as described in the [`configuration`](/docs/configuration#alias) docs.
6
6
7
-
```js
8
-
/// file: svelte.config.js
9
-
// @filename: ambient.d.ts
10
-
declare module'path';
11
-
12
-
// @filename: index.js
13
-
importpathfrom'path';
14
-
15
-
/**@type{import('@sveltejs/kit').Config}*/
16
-
constconfig= {
17
-
kit: {
18
-
vite: {
19
-
resolve: {
20
-
alias: {
21
-
$utils:path.resolve('./src/utils')
22
-
}
23
-
}
24
-
}
25
-
}
26
-
};
27
-
28
-
exportdefaultconfig;
29
-
```
30
-
31
-
Then, to make TypeScript aware of the alias, add it to `tsconfig.json` (for TypeScript users) or `jsconfig.json`:
32
-
33
-
```json
34
-
{
35
-
"compilerOptions": {
36
-
"paths": {
37
-
"$utils/*": ["src/utils/*"]
38
-
}
39
-
}
40
-
}
41
-
```
7
+
Then run `npm run sync` or `npm run dev` (which will execute `sync`). SvelteKit will automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
Copy file name to clipboardExpand all lines: packages/kit/types/ambient.d.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -88,7 +88,7 @@ declare module '$app/env' {
88
88
*/
89
89
declare module '$app/navigation'{
90
90
/**
91
-
* If called when the page is being updated following a navigation (in `onMount` or an action, for example), this disables SvelteKit's built-in scroll handling.
91
+
* If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling.
92
92
* This is generally discouraged, since it breaks user expectations.
0 commit comments