そこにはいくつかの質問がありますが、ほとんどの答えは「VS 2017を使用している場合は、現在デフォルトになっているはずです」のようです。デバッガーが機能しないので、特定のケースを挙げて助けを求めたいと思います。コンテキストを説明するために、TypescriptとWebpackも初めてです。
プロジェクト階層
./wwwroot/bundles/bundle.js <- this is the final bundled file
./Scripts/ <- various directories where all the separate Typescript files live
プロジェクトがビルドされると、次の手順が実行されます。
tsconfig.jsonファイルの内容
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"target": "es2015",
"moduleResolution": "node",
"module": "es2015"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
webpack.config.jsファイルの内容
module.exports = {
mode: 'development',
entry: './Scripts/index.ts',
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
output: {
filename: 'bundle.js'
}
};
タイプスクリプトをコンパイルして最終的な宛先に配置するgulpタスク。
gulp.task("compile-typescript", function () {
return gulp.src("./Scripts/index.ts")
.pipe(webpack(require("./webpack.config.js")))
.pipe(gulp.dest("./wwwroot/bundles"));
});
すべてがコンパイルされて実行された後、Visual Studio IDEにブレークポイントを設定すると、「ブレークポイントがバインドされていない」という問題が発生します。ただし、Chromeのデバッガーを見ると、TypeScriptマッピングファイルがwebpackディレクトリに正しく作成されているようです。
この回答からの行を追加することによって:https://stackoverflow.com/a/56512126/5245385私のwebpack.config.jsにそれを機能させることができました!! 視認性のために以下に貼り付けました:
devtool: false,
plugins: [
new webpack.SourceMapDevToolPlugin({
filename: "[file].map",
fallbackModuleFilenameTemplate: '[absolute-resource-path]',
moduleFilenameTemplate: '[absolute-resource-path]'
})
]
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加