Skip to content

Commit d41504b

Browse files
committed
refactor(@angular-devkit/build-angular): only inline component stylesheet sourcemaps
This change also ensures that hidden sourcemaps will be propagated through the loader chain and are extracted for global stylesheets.
1 parent d076aee commit d41504b

File tree

1 file changed

+10
-9
lines changed
  • packages/angular_devkit/build_angular/src/webpack/configs

1 file changed

+10
-9
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/styles.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,14 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
191191
}
192192

193193
const { supportedBrowsers } = new BuildBrowserFeatures(wco.projectRoot);
194-
const postcssOptionsCreator = (sourceMap: boolean, extracted: boolean | undefined) => {
194+
const postcssOptionsCreator = (inlineSourcemaps: boolean, extracted: boolean | undefined) => {
195195
return (loader: webpack.loader.LoaderContext) => ({
196-
map: sourceMap && {
197-
inline: true,
198-
annotation: false,
199-
},
196+
map: inlineSourcemaps
197+
? {
198+
inline: true,
199+
annotation: false,
200+
}
201+
: undefined,
200202
plugins: [
201203
postcssImports({
202204
resolve: (url: string) => url.startsWith('~') ? url.substr(1) : url,
@@ -264,8 +266,6 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
264266

265267
// load global css as css files
266268
if (globalStylePaths.length > 0) {
267-
const globalSourceMap = !!cssSourceMap && !buildOptions.sourceMap.hidden;
268-
269269
rules.push(
270270
...baseRules.map(({ test, use }) => {
271271
return {
@@ -281,14 +281,15 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
281281
loader: require.resolve('css-loader'),
282282
options: {
283283
url: false,
284-
sourceMap: globalSourceMap,
284+
sourceMap: !!cssSourceMap,
285285
},
286286
},
287287
{
288288
loader: require.resolve('postcss-loader'),
289289
options: {
290290
implementation: require('postcss'),
291-
postcssOptions: postcssOptionsCreator(globalSourceMap, buildOptions.extractCss),
291+
postcssOptions: postcssOptionsCreator(false, buildOptions.extractCss),
292+
sourceMap: !!cssSourceMap,
292293
},
293294
},
294295
...use,

0 commit comments

Comments
 (0)