-
Notifications
You must be signed in to change notification settings - Fork 12k
fix(build): override publicPath for ExtractTextPlugin #4036
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
Conversation
@changLiuUNSW can you add a test for this case? I want to ensure we don't break it in the future. A good test would be new file |
d56a661
to
19efaa1
Compare
@filipesilva |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a change I'm requesting regarding correctness that is important (checking the generated path), the others are minor changes.
// build with deloyUrl | ||
.then(() => ng('build', '--deploy-url=client/')) | ||
.then(() => expectFileToMatch('dist/styles.bundle.css', | ||
/div\s*{\s*background:\s*url\(more.svg\);\s*}/)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm the path here? If I get the issue correctly, this test would pass even without your fixe since it's just checks that there is an url that has more.svg
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without my fix, when we add --deploy-url=client/
, the result is:
div { background: url(client/more.svg); }
Test will fail in this case.
.then(() => ng('build')) | ||
.then(() => expectFileToMatch('dist/styles.bundle.css', | ||
/div\s*{\s*background:\s*url\(more.svg\);\s*}/)) | ||
.then(() => ng('build', '--prod')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to test the prod builds, it shouldn't change anything regarding --extract-css
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.then(() => ng('build', '--deploy-url=client/')) | ||
.then(() => expectFileToMatch('dist/styles.bundle.css', | ||
/div\s*{\s*background:\s*url\(more.svg\);\s*}/)) | ||
.then(() => ng('build', '--prod', '--deploy-url=client/')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for prod test, see above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.then((stylesBundle) => expectFileToMatch(stylesBundle, | ||
/div\s*{\s*background:\s*url\(more\..*svg\)\s*}/)) | ||
// build with deloyUrl | ||
.then(() => ng('build', '--deploy-url=client/')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you force --extract-css
here just to be more explicit to the next person editing this test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
19efaa1
to
1a677c4
Compare
Thanks for this fix @changLiuUNSW! |
I'm having an issue which relates to this issue I think (paths replaced). The project was initialised with a a previous version of angular-cli Error: No errors |
@korve please see #4264 |
Thank you @intellix! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
All our CSS assets are in a flat structure in the
dist
folder, therefore all relative URLs are simply./[asset name]
Unfortunately, if we add
publicPath
viadeployUrl
,ExtractTextPlugin
picks up theoutput.publicPath
and rewrites assetsurl
path with[publicPath]/[asset name]
fixes #4035