Skip to content

PostCSS handling of absolute deployUrl paths #10200

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

Closed
wants to merge 2 commits into from

Conversation

andrewtaylor
Copy link

When a deployUrl consists of an absolute path, it needs to be prepended to the outputUrl since url.resolve will just ignore it. The proposed patch simply checks for an absolute path to perform a prepend, falling back to the existing logic otherwise.

Without this patch resources within stylesheets do not get their paths prefixed with the deployUrl if for example that deployUrl is "/static".

…ed to the outputUrl since url.resolve will just ignore it
…he deployUrl. Remove any trailing slash from the deployUrl itself.
@clydin
Copy link
Member

clydin commented Apr 6, 2018

This is operating as intended. /static and /static/ have two different meanings. The deployUrl, if used (base href is generally the more appropriate option), should end in a / if the last segment represents a directory and not a file.

@andrewtaylor
Copy link
Author

Setting to /static/ does fix it. However given the context of a deployUrl, it can only be a directory. Hence is there not a reasonable expectation that it either warns about a missing slash or adds it itself? It seems other parts of the code do the latter, for example

return `${deployUrl.replace(/\/$/, '')}${url}`;
.

@clydin
Copy link
Member

clydin commented Apr 6, 2018

There's a more in-depth discussion on the deployUrl option in this PR: #8740.

If the goal is to normalize the deploy URL to always refer to a directory, then similar code to the above linked PR should be placed after this line in the configuration builder: https://github.com/angular/angular-cli/blob/1.7.x/packages/%40angular/cli/models/webpack-config.ts#L41

As an aside, in general, anywhere that someone attempts to use deploy URL, they should be using the base href option instead. For a comparison, see here: https://github.com/angular/angular-cli/blob/master/docs/design/deployurl-basehref.md

@andrewtaylor
Copy link
Author

You are correct, I was looking for the "more complicated setup" with baseHref "/static/" and APP_BASE_HREF "/". Thanks for that link explaining the difference..

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants