Skip to content

Commit 9d5772c

Browse files
Webview - Add Import Path Aliasing (RooCodeInc#2673)
* add import path aliasing * changeset * shared directory path aliasing
1 parent c7dad1a commit 9d5772c

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

.changeset/olive-months-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Add import path aliasing to the webview

webview-ui/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useEffect, useState } from "react"
22
import { useEvent } from "react-use"
3-
import { ExtensionMessage } from "../../src/shared/ExtensionMessage"
3+
import { ExtensionMessage } from "@shared/ExtensionMessage"
44
import ChatView from "./components/chat/ChatView"
55
import HistoryView from "./components/history/HistoryView"
66
import SettingsView from "./components/settings/SettingsView"

webview-ui/src/components/mcp/tabs/AddRemoteServerForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useCallback, useRef, useState } from "react"
22
import { vscode } from "../../../utils/vscode"
33
import { VSCodeButton, VSCodeLink, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
44
import { useEvent } from "react-use"
5-
import { LINKS } from "../../../constants"
5+
import { LINKS } from "@/constants"
66
const AddRemoteServerForm = ({ onServerAdded }: { onServerAdded: () => void }) => {
77
const [serverName, setServerName] = useState("")
88
const [serverUrl, setServerUrl] = useState("")

webview-ui/tsconfig.app.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@
1818
/* Linting */
1919
"strict": true,
2020
"noFallthroughCasesInSwitch": true,
21-
"noUncheckedSideEffectImports": true
21+
"noUncheckedSideEffectImports": true,
22+
23+
/* Aliasing */
24+
"baseUrl": ".",
25+
"paths": {
26+
"@/*": ["src/*"],
27+
"@components/*": ["src/components/*"],
28+
"@context/*": ["src/context/*"],
29+
"@shared/*": ["../src/shared/*"],
30+
"@utils/*": ["src/utils/*"]
31+
}
2232
},
2333
"include": ["src"],
2434
"exclude": ["src/**/__tests__/**"]

webview-ui/vite.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { defineConfig } from "vite"
44
import tailwindcss from "@tailwindcss/vite"
55
import react from "@vitejs/plugin-react-swc"
6+
import { resolve } from "path"
67

78
export default defineConfig({
89
plugins: [react(), tailwindcss()],
@@ -45,4 +46,13 @@ export default defineConfig({
4546
IS_DEV: JSON.stringify(process.env.IS_DEV),
4647
},
4748
},
49+
resolve: {
50+
alias: {
51+
"@": resolve(__dirname, "./src"),
52+
"@components": resolve(__dirname, "./src/components"),
53+
"@context": resolve(__dirname, "./src/context"),
54+
"@shared": resolve(__dirname, "../src/shared"),
55+
"@utils": resolve(__dirname, "./src/utils"),
56+
},
57+
},
4858
})

0 commit comments

Comments
 (0)