1. 程式人生 > >Egret之Visual Studio Code環境配置

Egret之Visual Studio Code環境配置

Egret Visual Studio Code VSC

一 : 為VSC安裝插件 , 一共為2個

1‘ 是Chrome插件 , 2‘ Egret插件
具體步驟
①:
技術分享圖片
②:
技術分享圖片
③:
技術分享圖片

二 : 配置 launch.json / tasks.json

1‘ 按 F5 選擇 Chrome , 可以生成 launch.json
技術分享圖片

2‘ 配置launch.json
①,加入配置:

        {
            "name": "使用本機 Chrome 調試",
            "type": "chrome",
            "request": "launch",
            // "file": "index.html",
            "url": "http://10.10.20.120:3000/index.html", //使用外部服務器時,請註釋掉 file, 改用 url, 並將 useBuildInServer 設置為 false "http://mysite.com/index.html
            "runtimeExecutable": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", // 改成您的 Chrome 安裝路徑
            "sourceMaps": true,
            "webRoot": "${workspaceRoot}",
            "preLaunchTask":"build",
            "userDataDir":"${tmpdir}",
            "port":5433
        }

如下圖:
技術分享圖片

3‘ 配置tasks.json
原始文件:
技術分享圖片

換成如下文件:

{
    "version": "0.1.0",
    "command": "egret",
    "isShellCommand": true,
    "tasks": [
        {
            "taskName": "build",
            "showOutput": "always",
            "args": [
                "build",
                "-sourcemap"
            ],
            "problemMatcher": "$tsc"
        },
        {
            "taskName": "clean",
            "showOutput": "always",
            "args": [
                "build",
                "-e"
            ],
            "problemMatcher": "$tsc"
        },
        {
            "taskName": "publish",
            "showOutput": "always",
            "args": [
                "publish"
            ],
            "problemMatcher": "$tsc"
        }
    ]
}

結果如下:
技術分享圖片

三 : ctrl +shift + p -> egret StartServer

開始啟動遊戲吧.........

Egret之Visual Studio Code環境配置