wails/website/i18n/de/docusaurus-plugin-content-docs/current/guides/vscode.mdx
2026-03-13 00:08:05 +00:00

82 lines
2.8 KiB
Text

# Visual Studio Code
Diese Seite ist für verschiedene Tipps und Tricks für die Verwendung von Visual Studio Code mit Wails.
## Vetur Konfiguration
Vielen Dank an [@Lyimmi](https://github.com/Lyimmi) für diesen Tipp. Ursprünglich [hier](https://github.com/wailsapp/wails/issues/1791#issuecomment-1228158349) veröffentlicht.
Vetur ist ein beliebtes Plugin für Visual Studio Code, das Syntaxhervorhebung und Code-Fertigstellung für Vue Projekte bereitstellt. Beim Laden eines Wails Projekts in VSCode wirft Vetur einen Fehler, da erwartet wird, dass sich das Frontend-Projekt im Root-Verzeichnis befindet. Um das zu beheben, kannst du Folgendes tun:
Erstelle eine Datei mit dem Namen `vetur.config.js` im Stammverzeichnis des Projekts.
```javascript
// vetur.config.js
/** @type {import('vls').VeturConfig} */
module.exports = {
// **optional** default: `{}`
// override vscode settings
// Notice: It only affects the settings used by Vetur.
settings: {
"vetur.useWorkspaceDependencies": true,
"vetur.experimental.templateInterpolationService": true
},
// **optional** default: `[{ root: './' }]`
// support monorepos
projects: [
{
// **required**
// Where is your project?
// It is relative to `vetur.config.js`.
// root: './packages/repo1',
root: './frontend',
// **optional** default: `'package.json'`
// Where is `package.json` in the project?
// We use it to determine the version of vue.
// It is relative to root property.
package: './package.json',
// **optional**
// Where is TypeScript config file in the project?
// It is relative to root property.
tsconfig: './tsconfig.json',
// **optional** default: `'./.vscode/vetur/snippets'`
// Where is vetur custom snippets folders?
snippetFolder: './.vscode/vetur/snippets',
// **optional** default: `[]`
// Register globally Vue component glob.
// If you set it, you can get completion by that components.
// It is relative to root property.
// Notice: It won't actually do it. You need to use `require.context` or `Vue.component`
globalComponents: [
'./src/components/**/*.vue'
]
}
]
}
```
Als nächstes konfiguriere `frontend/tsconfig.json`:
```javascript
{
"compilerOptions": {
"module": "system",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"outFile": "../../built/local/tsc.js",
"allowJs": true
},
"exclude": [
"node_modules",
"**/*.spec.ts"
],
"include": [
"src/**/*",
"wailsjs/**/*.ts"
]
}
```
Das sollte es ermöglichen, Vetur wie erwartet zu verwenden.