Skip to content

fix(build): Don't specify the extract-css option as precondition for css sourcemaps #8294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/@angular/cli/models/webpack-configs/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
// style-loader does not support sourcemaps without absolute publicPath, so it's
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this completely fixes the issue, then this comment should be removed.

// better to disable them when not extracting css
// https://github.com/webpack-contrib/style-loader#recommended-configuration
const cssSourceMap = buildOptions.extractCss && buildOptions.sourcemaps;
const cssSourceMap = buildOptions.sourcemaps;

// Minify/optimize css in production.
const minimizeCss = buildOptions.target === 'production';
Expand Down Expand Up @@ -199,8 +199,12 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
const ret: any = {
include: globalStylePaths,
test,
        use: buildOptions.extractCss ? ExtractTextPlugin.extract(extractTextPlugin)
: ['style-loader', ...extractTextPlugin.use]
use: buildOptions.extractCss ? ExtractTextPlugin.extract(extractTextPlugin) : [{
loader: 'style-loader',
options: {
convertToAbsoluteUrls: cssSourceMap,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed. From looking at this code, the option is automatically enabled if the stylesheet has a source map and the setting is undefined.

},
}, ...extractTextPlugin.use],
};
// Save the original options as arguments for eject.
if (buildOptions.extractCss) {
Expand Down