Skip to content

Commit

Permalink
fix(@angular/cli): standardize inline/rebase stylesheet behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin authored and Brocco committed Jan 19, 2018
1 parent c38b1ed commit f2ea3d1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/@angular/cli/models/webpack-configs/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
const extraPlugins: any[] = [];
const cssSourceMap = buildOptions.sourcemaps;

// Maximum resource size to inline (KiB)
const maximumInlineSize = 10;
// Minify/optimize css in production.
const minimizeCss = buildOptions.target === 'production';
// Convert absolute resource URLs to account for base-href and deploy-url.
Expand Down Expand Up @@ -110,12 +112,15 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
},
{
// TODO: inline .cur if not supporting IE (use browserslist to check)
filter: (asset: PostcssUrlAsset) => !asset.hash && !asset.absolutePath.endsWith('.cur'),
filter: (asset: PostcssUrlAsset) => {
return maximumInlineSize > 0 && !asset.hash && !asset.absolutePath.endsWith('.cur');
},
url: 'inline',
// NOTE: maxSize is in KB
maxSize: 10,
maxSize: maximumInlineSize,
fallback: 'rebase',
}
},
{ url: 'rebase' },
]),
autoprefixer(),
];
Expand All @@ -126,7 +131,7 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
'postcss-url': 'postcssUrl',
'postcss-import': 'postcssImports',
},
variables: { minimizeCss, baseHref, deployUrl, projectRoot }
variables: { minimizeCss, baseHref, deployUrl, projectRoot, maximumInlineSize }
};

// determine hashing format
Expand Down

0 comments on commit f2ea3d1

Please sign in to comment.