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
varisDevBuild=process.argv.indexOf('--env.prod')<0;
22
varpath=require('path');
33
varwebpack=require('webpack');
4+
varSourceMapDevToolPlugin=require('aspnet-webpack').SourceMapDevToolPlugin;
45
varnodeExternals=require('webpack-node-externals');
56
varmerge=require('webpack-merge');
67
varallFilenamesExceptJavaScript=/\.(?!js(\?|$))([^.]+(\?|$))/;
@@ -26,13 +27,15 @@ var sharedConfig ={
2627
varclientBundleConfig=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
newwebpack.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+
newSourceMapDevToolPlugin({moduleFilenameTemplate: '../../[resourcePath]'})// Compiled output is at './wwwroot/dist/', but sources are relative to './'
38+
] : [
3639
// Plugins that apply in production builds only
3740
newwebpack.optimize.OccurenceOrderPlugin(),
3841
newwebpack.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
varpath=require('path');
33
varwebpack=require('webpack');
44
varExtractTextPlugin=require('extract-text-webpack-plugin');
5+
varSourceMapDevToolPlugin=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+
newSourceMapDevToolPlugin({moduleFilenameTemplate: '../../[resourcePath]'})// Compiled output is at './wwwroot/dist/', but sources are relative to './'
31+
] : [
2932
// Plugins that apply in production builds only
3033
newwebpack.optimize.OccurenceOrderPlugin(),
3134
newwebpack.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
varpath=require('path');
33
varwebpack=require('webpack');
44
varExtractTextPlugin=require('extract-text-webpack-plugin');
5+
varSourceMapDevToolPlugin=require('aspnet-webpack').SourceMapDevToolPlugin;
56
varnodeExternals=require('webpack-node-externals');
67
varmerge=require('webpack-merge');
78
varallFilenamesExceptJavaScript=/\.(?!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
newExtractTextPlugin('site.css'),
3737
newwebpack.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+
newSourceMapDevToolPlugin({moduleFilenameTemplate: '../../[resourcePath]'})// Compiled output is at './wwwroot/dist/', but sources are relative to './'
44+
] : [
4245
// Plugins that apply in production builds only
4346
newwebpack.optimize.OccurenceOrderPlugin(),
4447
newwebpack.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
varpath=require('path');
33
varwebpack=require('webpack');
44
varExtractTextPlugin=require('extract-text-webpack-plugin');
5+
varSourceMapDevToolPlugin=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+
newSourceMapDevToolPlugin({moduleFilenameTemplate: '../../[resourcePath]'})// Compiled output is at './wwwroot/dist/', but sources are relative to './'
32+
] : [
2933
// Plugins that apply in production builds only
3034
newwebpack.optimize.OccurenceOrderPlugin(),
3135
newwebpack.optimize.UglifyJsPlugin({compress: {warnings: false}}),
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
varSourceMapDevToolPlugin=require('aspnet-webpack').SourceMapDevToolPlugin;
2+
13
module.exports={
2-
devtool: 'inline-source-map'
4+
plugins: [
5+
newSourceMapDevToolPlugin({moduleFilenameTemplate: '../../[resourcePath]'})// Compiled output is at './wwwroot/dist/', but sources are relative to './'
6+
]
37
};

0 commit comments

Comments
(0)