Skip to content

Commit 6b903d5

Browse files
committed
feat: Add @ alias to ./src
1 parent 14479d3 commit 6b903d5

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/hello.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
22
import { onDestroy, onMount } from "svelte";
3-
import { version } from "./api";
3+
import { version } from "@/api";
44
import { showMessage } from "siyuan";
5-
import Typo from "./libs/b3-typography.svelte";
5+
import Typo from "@/libs/b3-typography.svelte";
66
77
export let name: string;
88
export let i18n: any;

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {
1010
getBackend,
1111
IModel
1212
} from "siyuan";
13-
import "./index.scss";
13+
import "@/index.scss";
1414

15-
import HelloExample from "./hello.svelte";
16-
import SettingPannel from "./libs/setting-panel.svelte";
15+
import HelloExample from "@/hello.svelte";
16+
import SettingPannel from "@/libs/setting-panel.svelte";
1717

1818
const STORAGE_NAME = "menu-config";
1919
const TAB_TYPE = "custom_tab";

tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
"node",
3636
"vite/client",
3737
"svelte"
38-
]
38+
],
39+
"baseUrl": "./src",
40+
"paths": {
41+
"@/*": ["*"],
42+
"@/libs/*": ["libs/*"],
43+
}
3944
},
4045
"include": [
4146
"tools/**/*.ts",

vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ console.log("isWatch=>", isWatch)
1616
console.log("distDir=>", distDir)
1717

1818
export default defineConfig({
19+
resolve: {
20+
alias: {
21+
"@": resolve(__dirname, "src"),
22+
}
23+
},
24+
1925
plugins: [
2026
svelte(),
2127

0 commit comments

Comments
 (0)