Skip to content

Commit 1c5e88f

Browse files
changLiuUNSWMRHarrison
authored andcommitted
fix(build): override publicPath for ExtractTextPlugin and add extract-css test (angular#4036)
1 parent a948b78 commit 1c5e88f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: packages/angular-cli/models/webpack-build-utils.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export function makeCssLoaders(stylePaths: string[] = []) {
8080
include: stylePaths, test, loaders: ExtractTextPlugin.extract({
8181
remove: false,
8282
loader: ['css-loader', ...commonLoaders, ...loaders],
83-
fallbackLoader: 'style-loader'
83+
fallbackLoader: 'style-loader',
84+
// publicPath needed as a workaround https://github.com/angular/angular-cli/issues/4035
85+
publicPath: ''
8486
})
8587
})));
8688
}

Diff for: tests/e2e/tests/build/styles/extract-css.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { writeMultipleFiles, expectFileToMatch } from '../../../utils/fs';
2+
import { ng } from '../../../utils/process';
3+
import { stripIndents } from 'common-tags';
4+
5+
export default function () {
6+
return writeMultipleFiles({
7+
'src/styles.css': stripIndents`
8+
div { background: url("./assets/more.svg"); }
9+
`,
10+
'src/assets/more.svg': stripIndents`
11+
<svg width="100" height="100">
12+
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
13+
</svg>
14+
`})
15+
.then(() => ng('build', '--extract-css'))
16+
.then(() => expectFileToMatch('dist/styles.bundle.css',
17+
/div\s*{\s*background:\s*url\(more.svg\);\s*}/))
18+
.then(() => ng('build', '--extract-css', '--deploy-url=client/'))
19+
.then(() => expectFileToMatch('dist/styles.bundle.css',
20+
/div\s*{\s*background:\s*url\(more.svg\);\s*}/));
21+
}

0 commit comments

Comments
 (0)