[英]How to debug webpacked TypeScript in VS 2017
我正在使用带有ts-loader的webpack来转换和捆绑各种TypeScript文件。 这是我的配置:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"noImplicitAny": true,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "es2015",
"lib": [ "dom", "es2015", "es2016" ],
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"preserveConstEnums": true,
"skipLibCheck": true
},
"include": [
"node_modules/@types/**/*.d.ts",
"src/**/*.ts"
]
}
webpack.config.js
var path = require('path');
module.exports = {
context: path.join(__dirname, 'src'),
entry: {
app: './app'
},
output: {
path: path.join(__dirname, 'dist/'),
filename: '[name].bundle.js'
},
resolve: {
extensions: ['.js','.ts']
},
module: {
loaders: [{
test: /\.ts$/,
loaders: ['ts-loader'],
exclude: /(node_modules|bower_components)/
}]
},
devtool: 'inline-source-map'
};
我的文件夹被组织为
/src
/dist
在src文件夹中,我有.ts文件和typescript编译器创建的pre-webpack js和.map文件(通过ts-loader)。 在dist文件夹中,我得到了带有内联源映射的webpacked js。 我的html页面引用了webpacked js。 当我在VS中运行项目并在原始.ts文件中设置断点时,断点显示“断点当前不会被命中。此文档没有加载任何符号。” 当然它没有被击中。 如何使源映射工作以便能够在我的原始TypeScript中进行调试?
更新:当webpack不在混合中时,VS中的TypeScript调试可以正常使用IE或Chrome。 这是导致问题的webpack的添加。
假设您正在使用angular cli:run ng serve
在localhost:4200上打开浏览器并检查页面。 找到webpack / src / fileyouwanttodebug,放置断点和刷新页面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.