From 8273e27371a1a32d24d2fedf135eb821d773b84d Mon Sep 17 00:00:00 2001 From: Charles Lyding Date: Wed, 14 Jun 2017 11:26:32 -0400 Subject: [PATCH] fix(@angular/cli): correct sourcemap source paths --- packages/@angular/cli/models/webpack-configs/common.ts | 10 +++++++++- packages/@angular/cli/tasks/eject.ts | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/@angular/cli/models/webpack-configs/common.ts b/packages/@angular/cli/models/webpack-configs/common.ts index ed1a6873d978..a2a2707c8b12 100644 --- a/packages/@angular/cli/models/webpack-configs/common.ts +++ b/packages/@angular/cli/models/webpack-configs/common.ts @@ -63,8 +63,16 @@ export function getCommonConfig(wco: WebpackConfigOptions) { extraPlugins.push(new ProgressPlugin({ profile: buildOptions.verbose, colors: true })); } + if (buildOptions.sourcemaps) { + extraPlugins.push(new webpack.SourceMapDevToolPlugin({ + filename: '[file].map[query]', + moduleFilenameTemplate: '[resource-path]', + fallbackModuleFilenameTemplate: '[resource-path]?[hash]', + sourceRoot: 'webpack:///' + })); + } + return { - devtool: buildOptions.sourcemaps ? 'source-map' : false, resolve: { extensions: ['.ts', '.js'], modules: ['node_modules', nodeModules], diff --git a/packages/@angular/cli/tasks/eject.ts b/packages/@angular/cli/tasks/eject.ts index 11421c91b522..0682cbb990ba 100644 --- a/packages/@angular/cli/tasks/eject.ts +++ b/packages/@angular/cli/tasks/eject.ts @@ -158,6 +158,9 @@ class JsonWebpackSerializer { case (webpack).HashedModuleIdsPlugin: this._addImport('webpack', 'HashedModuleIdsPlugin'); break; + case webpack.SourceMapDevToolPlugin: + this._addImport('webpack', 'SourceMapDevToolPlugin'); + break; case webpack.optimize.UglifyJsPlugin: this._addImport('webpack.optimize', 'UglifyJsPlugin'); break;