我使用Google Closure生成縮小的JS /源圖,無法獲取源圖將源連接到Chrome中「Sources」窗口中的縮小腳本。從Google Closure compiler documentationGoogle Closure源圖未連接Chrome中的源代碼
我的源採取
代碼是這個(hello.js):
// A simple function.
function hello(longName) {
alert('Hello, ' + longName);
}
hello('New User');
我的編譯器執行的命令是:
java -jar compiler.jar --js hello.js --js_output_file hello.min.js --create_source_map hello.min.js.map
這成功地執行,並且產生:
Minified source(hello.min.js):
function hello(a){alert("Hello, "+a)}hello("New User");
我添加以下行hello.min.js的端部如在this article
//@ sourceMappingURL=hello.min.js.map
一切建議,包括源映射,是在相同的目錄和源映射在Chrome被啓用。 index.html頁面在body標籤中僅包含hello.min.js。
任何人都可以看到我做錯了嗎?我非常感謝任何幫助。
謝謝
你看着源地圖的內容是什麼?你可以從列出的位置加載源代碼嗎? – John
源地圖列出[「hello.js」]作爲「sources」鍵的值,並正確加載此文件。 – user2394200
您是否看到請求源地圖的HTTP請求並返回了正確的內容? – John