Skip to content

Commit

Permalink
fix(build): override publicPath for ExtractTextPlugin and add extract…
Browse files Browse the repository at this point in the history
…-css test (angular#4036)
  • Loading branch information
changLiuUNSW authored and MRHarrison committed Feb 9, 2017
1 parent a948b78 commit 1c5e88f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/angular-cli/models/webpack-build-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export function makeCssLoaders(stylePaths: string[] = []) {
include: stylePaths, test, loaders: ExtractTextPlugin.extract({
remove: false,
loader: ['css-loader', ...commonLoaders, ...loaders],
fallbackLoader: 'style-loader'
fallbackLoader: 'style-loader',
// publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
publicPath: ''
})
})));
}
Expand Down
21 changes: 21 additions & 0 deletions tests/e2e/tests/build/styles/extract-css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { writeMultipleFiles, expectFileToMatch } from '../../../utils/fs';
import { ng } from '../../../utils/process';
import { stripIndents } from 'common-tags';

export default function () {
return writeMultipleFiles({
'src/styles.css': stripIndents`
div { background: url("./assets/more.svg"); }
`,
'src/assets/more.svg': stripIndents`
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
`})
.then(() => ng('build', '--extract-css'))
.then(() => expectFileToMatch('dist/styles.bundle.css',
/div\s*{\s*background:\s*url\(more.svg\);\s*}/))
.then(() => ng('build', '--extract-css', '--deploy-url=client/'))
.then(() => expectFileToMatch('dist/styles.bundle.css',
/div\s*{\s*background:\s*url\(more.svg\);\s*}/));
}

0 comments on commit 1c5e88f

Please sign in to comment.