メインコンテンツにスキップ
バージョン: 次期バージョン 🚧

統合開発環境

Wailsでは、優れた開発体験の提供を目指しています。 その一環として、統合開発環境特有の構成設定の生成をサポートしており、より快適にプロジェクトをセットアップできるようになっています。

現在はVisual Studio Codeをサポートしていますが、今後、Golandなど他の統合開発環境もサポートしていく予定です。

Visual Studio Code

プロジェクト生成時のコマンドに-ide vscodeフラグを付与すると、統合開発環境用の構成ファイルが、他のプロジェクトファイルと共に作成されます。 これらのファイルは.vscodeディレクトリ内に配置され、アプリケーションをデバッグするための正しい構成設定が記述されています。

生成されるのはtasks.jsonファイルおよびlaunch.jsonファイルの2つです。 デフォルトのバニラプロジェクトの場合、次のような内容となります:

tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}"
},
"command": "go",
"args": [
"build",
"-tags",
"dev",
"-gcflags",
"all=-N -l",
"-o",
"build/bin/myproject.exe"
]
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Wails: Debug myproject",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "${workspaceFolder}/build/bin/myproject.exe",
"preLaunchTask": "build",
"cwd": "${workspaceFolder}",
"env": {}
}
]
}

インストールおよびビルドステップの構成

デフォルトのプロジェクトでは、npm installnpm run buildなどのステップが必要ないため、tasks.jsonファイルの内容なシンプルなものになっています。 Svelteテンプレートのように、フロントエンドのビルドステップが必要なプロジェクトの場合、tasks.jsonを編集して、インストールおよびビルドのステップを追加する必要があります。

tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "npm install",
"type": "npm",
"script": "install",
"options": {
"cwd": "${workspaceFolder}/frontend"
},
"presentation": {
"clear": true,
"panel": "shared",
"showReuseMessage": false
},
"problemMatcher": []
},
{
"label": "npm run build",
"type": "npm",
"script": "build",
"options": {
"cwd": "${workspaceFolder}/frontend"
},
"presentation": {
"clear": true,
"panel": "shared",
"showReuseMessage": false
},
"problemMatcher": []
},
{
"label": "build",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}"
},
"command": "go",
"args": [
"build",
"-tags",
"dev",
"-gcflags",
"all=-N -l",
"-o",
"build/bin/vscode.exe"
],
"dependsOn": ["npm install", "npm run build"]
}
]
}

今後の機能強化予定

将来的に、インストールおよびビルドステップを含んだtasks.jsonを自動生成できるように計画しています。

:::