我正在尝试调试NestJS应用程序,该应用程序具有在官方文档中描述的webpack HMR设置
这是我的VSCode launch.json
文件:
{
"name": "Attach",
"request": "attach",
"type": "node",
"restart": true,
"sourceMaps": true,
"internalConsoleOptions": "neverOpen",
"localRoot": "${workspaceFolder}/dist",
"skipFiles": [
// Ignore node_modules folder when debugging.
"${workspaceFolder}/node_modules/**/*.js",
// Ignore NodeJS when debugging.
"<node_internals>/**/*.js"
],
"outFiles": ["${workspaceFolder}/dist/**/**.js"],
"autoAttachChildProcesses": true
}
这里是webpack-hmt.config.json
文件。
const nodeExternals = require('webpack-node-externals');
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
module.exports = function (options, webpack) {
return {
...options,
devtool: 'inline-source-map',
entry: ['webpack/hot/poll?100', options.entry],
externals: [
nodeExternals({
allowlist: ['webpack/hot/poll?100'],
}),
],
plugins: [
...options.plugins,
new webpack.HotModuleReplacementPlugin(),
new webpack.WatchIgnorePlugin({
paths: [/\.js$/, /\.d\.ts$/],
}),
new RunScriptWebpackPlugin({
name: options.output.filename,
nodeArgs: ['--inspect=0.0.0.0:9229'],
}),
],
};
};
遗憾的是,当我运行调试器并在控制器中设置断点时,它们没有被触发。