Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion packages/@angular/cli/models/webpack-configs/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
postcssImports({
resolve: (url: string, context: string) => {
return new Promise<string>((resolve, reject) => {
if (url && url.startsWith('~')) {
url = url.substr(1);
}
loader.resolve(context, url, (err: Error, result: string) => {
if (err) {
reject(err);
Expand Down Expand Up @@ -110,7 +113,8 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
filter: (asset: PostcssUrlAsset) => !asset.hash && !asset.absolutePath.endsWith('.cur'),
url: 'inline',
// NOTE: maxSize is in KB
maxSize: 10
maxSize: 10,
fallback: 'rebase',
}
]),
autoprefixer(),
Expand Down
37 changes: 37 additions & 0 deletions tests/e2e/tests/build/styles/material-import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
writeMultipleFiles,
replaceInFile
} from '../../../utils/fs';
import { ng, silentNpm } from '../../../utils/process';
import { stripIndents } from 'common-tags';
import { updateJsonFile } from '../../../utils/project';

export default function () {
const extensions = ['css', 'scss', 'less', 'styl'];
let promise: Promise<any> = Promise.resolve()
.then(() => silentNpm('install', '@angular/[email protected]'));

extensions.forEach(ext => {
promise = promise.then(() => {
return writeMultipleFiles({
[`src/styles.${ext}`]: stripIndents`
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
`,
[`src/app/app.component.${ext}`]: stripIndents`
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
`,
})
// change files to use preprocessor
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['styles'] = [`styles.${ext}`];
}))
.then(() => replaceInFile('src/app/app.component.ts',
'./app.component.css', `./app.component.${ext}`))
// run build app
.then(() => ng('build', '--extract-css', '--sourcemap'));
});
});

return promise;
}