Skip to content
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

fix(css): emit css sourcemaps only when extracting #4280

Merged
merged 1 commit into from
Jan 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/angular-cli/models/webpack-configs/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
const entryPoints: { [key: string]: string[] } = {};
const globalStylePaths: string[] = [];
const extraPlugins: any[] = [];
// style-loader does not support sourcemaps without absolute publicPath, so it's
// better to disable them when not extracting css
// https://github.com/webpack-contrib/style-loader#recommended-configuration
const cssSourceMap = buildOptions.extractCss && buildOptions.sourcemap;

// discard comments in production
const extraPostCssPlugins = buildOptions.target === 'production'
Expand Down Expand Up @@ -75,7 +79,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
// so we need to add options in its query
{
test: /\.styl$/, loaders: [`stylus-loader?${JSON.stringify({
sourceMap: buildOptions.sourcemap,
sourceMap: cssSourceMap,
paths: includePaths
})}`]
}
Expand All @@ -95,7 +99,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
loader: [
// css-loader doesn't support webpack.LoaderOptionsPlugin properly,
// so we need to add options in its query
`css-loader?${JSON.stringify({ sourceMap: buildOptions.sourcemap })}`,
`css-loader?${JSON.stringify({ sourceMap: cssSourceMap })}`,
...commonLoaders,
...loaders
],
Expand All @@ -121,14 +125,14 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
disable: !buildOptions.extractCss
}),
new webpack.LoaderOptionsPlugin({
sourceMap: true,
sourceMap: cssSourceMap,
options: {
postcss: [autoprefixer()].concat(extraPostCssPlugins),
// css-loader, stylus-loader don't support LoaderOptionsPlugin properly
// options are in query instead
sassLoader: { sourceMap: buildOptions.sourcemap, includePaths },
sassLoader: { sourceMap: cssSourceMap, includePaths },
// less-loader doesn't support paths
lessLoader: { sourceMap: buildOptions.sourcemap },
lessLoader: { sourceMap: cssSourceMap },
// context needed as a workaround https://github.com/jtangelder/sass-loader/issues/285
context: projectRoot,
},
Expand Down