如何在angular2中使用webpack作为模块绑定器时在开发者工具中获取.ts文件
我使用webpack作为模块包来开发angular2应用程序。它创建了bundle.js文件。我无法在开发工具中获取.ts文件以便调试它。有解决方案吗如何在angular2中使用webpack作为模块绑定器时在开发者工具中获取.ts文件,angular,typescript,webpack,webpack-2,Angular,Typescript,Webpack,Webpack 2,我使用webpack作为模块包来开发angular2应用程序。它创建了bundle.js文件。我无法在开发工具中获取.ts文件以便调试它。有解决方案吗 //var ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { entry: { 'app': "./App/main.ts", 'employee
//var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
'app': "./App/main.ts",
'employee': "./App/EmployeeModule/employee.module",
'supplier': "./App/SupplierModule/supplier.module",
'product': "./App/ProductModule/product.module"
},
output: {
path: __dirname + "/dist",
filename: "[name].js",
chunkFilename: "[id].chunk.js",
publicPath: "/dist/",
},
resolve: {
extensions: [".ts", ".js", ".json"]
},
module: {
rules:
[
{
test: /\.ts$/, loaders: ["ts-loader", "angular2-template-loader", "angular2-router-loader"]
},
{
test: /\.html$/, loader: "html-loader"
},
{
test: /\.css$/, loaders: ['style-loader', 'css-loader'] },
{
test: /\.jpe?g$|\.gif$|\.png$/i, loader: "file-loader"
},
{ test: /\.js$/, loader: "source-map-loader" }
],
},
}
使用
tsconfig.json
中为TypeScript启用源映射生成:
{
"compilerOptions": {
...
"sourceMap": true
}
}
webpack.config.js
中添加此链接,在生成的JavaScript文件中添加sourcemaps链接:module.exports={
devtool:“源映射”
};