VS Code: “Breakpoint ignored because generated code not found” error

前端 未结 18 2639
无人共我
无人共我 2020-12-13 08:07

I have looked everywhere and I still have issue debugging TypeScript inside VS Code. I have read this thread but still I am not able to hit my breakpoints placed inside a Ty

18条回答
  •  猫巷女王i
    2020-12-13 08:40

    After ripping my hair out all day, I finally got it to work.

    The problem is there's three files to fiddle with - launch.json, tsconfig.json, and webpack.config.js so it's all combinatorial.

    the diagnosticLogging was key to helping me figure it out.

    Microsoft please make this easier... Really, vscode could have figured this out or at least guided me more on the process.

    Anyway here's what finally worked in my launch.json:

    "url": "http://localhost:8080/",
    "sourceMaps": true,
    "webRoot": "${workspaceRoot}",
    "diagnosticLogging": true,
    "sourceMapPathOverrides": { "webpack:///src/*": "${workspaceRoot}/src/*" }
    

    my tsconfig.json:

    "outDir": "dist",
    "sourceMap": true
    

    my webpack.config.js:

    output: {
       path: 'dist/dev',
       filename: '[name].js'
    },
    ...
    module: {
        loaders: [...],
        preLoaders: [{
            test: /\.js$/,
            loader: "source-map-loader"
        }]
    }
    ...
    plugins: [
        new webpack.SourceMapDevToolPlugin(),
        ...
    ],
    devtool: "cheap-module-eval-source-map",
    

提交回复
热议问题