簡體   English   中英

在 Visual Studio 中捆綁打字稿文件而不​​會失去 Browserlink 功能

[英]Bundle typescript files in Visual Studio without loosing Browserlink feature

Visual Studio 可以在保存時自動編譯打字稿文件。 當使用瀏覽器鏈接時,它也會自動將瀏覽器更新為最新版本。

有沒有辦法在不丟失此功能的情況下在 Visual Studio 中捆綁打字稿文件? 代碼應在保存時重新編譯,並通過瀏覽器鏈接自動在瀏覽器中可用。

無論哪種解決方案都需要能夠解析 es6 模塊! 我在整個網絡上找到了一些解決方案,但他們大多使用 webpack(速度很慢)並且沒有提及它是否適用於 browserlink

您可以使用 Cloud Mate ( https://angrymonkeycloud.com/mate ) 但不確定瀏覽器鏈接!

它使用 gulp 編譯、捆綁和縮小 TypeScript 文件,而無需編寫 gulp 復雜配置。

  1. 通過 npm 在您的設備上全局安裝 cloud mate:
    npm install -g cloudmate
  1. 創建名為“mateconfig.json”的 JSON 配置文件,如下所示:
    {
        "files":  
        [
            {
                "output": ["js/index.js"],
                "input": ["src/file1.ts", "src/file2.ts"]
            }
        ],
        "builds":
        [
            {
                "name": "dev", // important
                "js": {
                    "minify": true,
                    "sourceMap": true,
                    "declaration": false,
                    "webClean": true // important to make it work on browsers
                },
                "ts": {
                    "compilerOptions": { // this is my working configuration
                        "target": "es5",
                        "noEmitOnError": false,
                        "noImplicitAny": false,
                        "module": "ES6"
                        "lib": [ "ES2015", "DOM" ]
                    }
                }
            }
        ]
    }
  1. 使用 CLI 執行
    cd {mateconfig.json file path}
    cloudmate -w // -w to keep watching files for updates

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM