実現したいこと
Chromeではデバッグできるので、VSCode上でもブレークポイントを使ってデバッグできるようにしたい。
発生している問題・分からないこと
VSCodeではsouceMapが読み込めずVSCodeでデバッグができない。どうやらsouceMapとトランスパイルされたjsが別のコンテンツと判定されている…?
エラーメッセージ
error
1[Debug Diagnostics:] 2 3 4✅ This breakpoint was initially set in: 5 6D:\Dropbox\Job\Engineering\uetax\src\scripts\module\CsvFileReader.ts line 37 column 1 7❓ We couldn't find a corresponding source location, and didn't find any source with the name CsvFileReader.ts. 8How did you expect this file to be loaded? (If you have a compilation step, you should pick 'sourcemap') 9 10--- 11 12http://localhost:9223/weekReport.bundle.js 13sourceReference: 1966746525 14absolutePath: 15absolutePath verified? ❌ Disk verification failed (does not exist or different content) 16sourcemap children: None (does not have a sourcemap) 17referenced from sourcemap: None (not from a sourcemap)
該当のソースコード
webpack.config.ts
1 2const config: Configuration = { 3 devtool: "source-map", 4 entry: { 5 weekReport: "./src/index.ts", 6 }, 7 8 output: { 9 path: path.join(__dirname, "dist"), 10 }, 11 12 module: { 13 rules: [ 14 { 15 // 拡張子 .ts の場合 16 test: /\.tsx?$/, 17 // TypeScript をコンパイルする 18 use: { 19 loader: "ts-loader", 20 options: { 21 transpileOnly: true, 22 configFile: "tsconfig.json", 23 }, 24 }, 25 }, 26 ], 27}; 28// 設定をデフォルトエクスポート 29export default config; 30
launch.json
1{ 2 "version": "0.2.0", 3 "configurations": [ 4 { 5 "type": "chrome", 6 "request": "launch", 7 "name": "Launch development server", 8 "url": "http://localhost:9223", 9 "webRoot": "${workspaceFolder}", 10 "preLaunchTask": "dev", 11 "skipFiles": ["<node_internals>/**"], 12 "trace": true, 13 "sourceMaps": true, 14 "resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"], 15 "sourceMapPathOverrides": { 16 "webpack:///./*": "${webRoot}/*", 17 "webpack://./src/*": "${webRoot}/src/*" 18 } 19 } 20 ] 21} 22
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
- launch.jsonに "resolveSourceMapLocations": ["${workspaceFolder}/", "!/node_modules/**"],を追加してみる
- sourceMapPathOverridesを変えてみる等
補足
フォルダー階層:
/proj
├─ .vscode
│ ├─ lanch.json
│ ├─ task.json
│ └─ www.code-wokspace
├─ dist
│ ├─ proj.bundle.js
│ ├─ proj.bundle.js.map
│ └─ index.html
├─ src
│ └─ ...
├─ package.json
├─ tsconfig.json
└─ webpack.config.ts

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。