Skip to content

Commit 30a6944

Browse files
Make source maps compatible with VS/VSCode debugging (fix file paths, and strip out the "charset=utf-8;" segments from inline sourceMappingURLs)
1 parent d20a72b commit 30a6944

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

templates/Angular2Spa/webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
22
var path = require('path');
33
var webpack = require('webpack');
4+
var SourceMapDevToolPlugin = require('aspnet-webpack').SourceMapDevToolPlugin;
45
var nodeExternals = require('webpack-node-externals');
56
var merge = require('webpack-merge');
67
var allFilenamesExceptJavaScript = /\.(?!js(\?|$))([^.]+(\?|$))/;
@@ -26,13 +27,15 @@ var sharedConfig = {
2627
var clientBundleConfig = merge(sharedConfig, {
2728
entry: { 'main-client': './ClientApp/boot-client.ts' },
2829
output: { path: path.join(__dirname, './wwwroot/dist') },
29-
devtool: isDevBuild ? 'inline-source-map' : null,
3030
plugins: [
3131
new webpack.DllReferencePlugin({
3232
context: __dirname,
3333
manifest: require('./wwwroot/dist/vendor-manifest.json')
3434
})
35-
].concat(isDevBuild ? [] : [
35+
].concat(isDevBuild ? [
36+
// Plugins that apply in development builds only
37+
new SourceMapDevToolPlugin({ moduleFilenameTemplate: '../../[resourcePath]' }) // Compiled output is at './wwwroot/dist/', but sources are relative to './'
38+
] : [
3639
// Plugins that apply in production builds only
3740
new webpack.optimize.OccurenceOrderPlugin(),
3841
new webpack.optimize.UglifyJsPlugin()

templates/KnockoutSpa/webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ var isDevBuild = process.argv.indexOf('--env.prod') < 0;
22
var path = require('path');
33
var webpack = require('webpack');
44
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
var SourceMapDevToolPlugin = require('aspnet-webpack').SourceMapDevToolPlugin;
56

67
module.exports = {
7-
devtool: isDevBuild ? 'inline-source-map' : null,
88
entry: { 'main': './ClientApp/boot.ts' },
99
resolve: { extensions: [ '', '.js', '.ts' ] },
1010
output: {
@@ -25,7 +25,10 @@ module.exports = {
2525
context: __dirname,
2626
manifest: require('./wwwroot/dist/vendor-manifest.json')
2727
})
28-
].concat(isDevBuild ? [] : [
28+
].concat(isDevBuild ? [
29+
// Plugins that apply in development builds only
30+
new SourceMapDevToolPlugin({ moduleFilenameTemplate: '../../[resourcePath]' }) // Compiled output is at './wwwroot/dist/', but sources are relative to './'
31+
] : [
2932
// Plugins that apply in production builds only
3033
new webpack.optimize.OccurenceOrderPlugin(),
3134
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),

templates/ReactReduxSpa/webpack.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var isDevBuild = process.argv.indexOf('--env.prod') < 0;
22
var path = require('path');
33
var webpack = require('webpack');
44
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
var SourceMapDevToolPlugin = require('aspnet-webpack').SourceMapDevToolPlugin;
56
var nodeExternals = require('webpack-node-externals');
67
var merge = require('webpack-merge');
78
var allFilenamesExceptJavaScript = /\.(?!js(\?|$))([^.]+(\?|$))/;
@@ -31,14 +32,16 @@ var clientBundleConfig = merge(sharedConfig(), {
3132
]
3233
},
3334
output: { path: path.join(__dirname, './wwwroot/dist') },
34-
devtool: isDevBuild ? 'inline-source-map' : null,
3535
plugins: [
3636
new ExtractTextPlugin('site.css'),
3737
new webpack.DllReferencePlugin({
3838
context: __dirname,
3939
manifest: require('./wwwroot/dist/vendor-manifest.json')
4040
})
41-
].concat(isDevBuild ? [] : [
41+
].concat(isDevBuild ? [
42+
// Plugins that apply in development builds only
43+
new SourceMapDevToolPlugin({ moduleFilenameTemplate: '../../[resourcePath]' }) // Compiled output is at './wwwroot/dist/', but sources are relative to './'
44+
] : [
4245
// Plugins that apply in production builds only
4346
new webpack.optimize.OccurenceOrderPlugin(),
4447
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })

templates/ReactSpa/webpack.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var isDevBuild = process.argv.indexOf('--env.prod') < 0;
22
var path = require('path');
33
var webpack = require('webpack');
44
var ExtractTextPlugin = require('extract-text-webpack-plugin');
5+
var SourceMapDevToolPlugin = require('aspnet-webpack').SourceMapDevToolPlugin;
56

67
module.exports = {
78
devtool: isDevBuild ? 'inline-source-map' : null,
@@ -25,7 +26,10 @@ module.exports = {
2526
context: __dirname,
2627
manifest: require('./wwwroot/dist/vendor-manifest.json')
2728
})
28-
].concat(isDevBuild ? [] : [
29+
].concat(isDevBuild ? [
30+
// Plugins that apply in development builds only
31+
new SourceMapDevToolPlugin({ moduleFilenameTemplate: '../../[resourcePath]' }) // Compiled output is at './wwwroot/dist/', but sources are relative to './'
32+
] : [
2933
// Plugins that apply in production builds only
3034
new webpack.optimize.OccurenceOrderPlugin(),
3135
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var SourceMapDevToolPlugin = require('aspnet-webpack').SourceMapDevToolPlugin;
2+
13
module.exports = {
2-
devtool: 'inline-source-map'
4+
plugins: [
5+
new SourceMapDevToolPlugin({ moduleFilenameTemplate: '../../[resourcePath]' }) // Compiled output is at './wwwroot/dist/', but sources are relative to './'
6+
]
37
};

0 commit comments

Comments
 (0)