Skip to content
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

Fix loading of styles in static build #2605

Merged
merged 2 commits into from
Feb 17, 2022
Merged

Conversation

matthewp
Copy link
Contributor

Changes

Testing

Test added

Docs

Bug fix only

@changeset-bot
Copy link

changeset-bot bot commented Feb 17, 2022

🦋 Changeset detected

Latest commit: 9c2c464

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) test labels Feb 17, 2022
function relativeToRoot(pathname: string) {
const arg = startsWithForwardSlash(pathname) ? '.' + pathname : pathname;
const url = new URL(arg, config.projectRoot);
return slash(fileURLToPath(url)) + url.search;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q. Is there a difference between slash(fileURLToPath(url)) and url.pathname? My understand is that URL would be the same as the slash’d version of the possibly-windows-style path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, url.pathname will contain %20 for a space whereas fileURLToPath removes the encoding and puts a space in. We ran into this bug before and its why the packages/astro/test/fixtures/static build project contains a space.

@matthewp matthewp merged commit 8776241 into main Feb 17, 2022
@matthewp matthewp deleted the static-build-style-import branch February 17, 2022 15:32
This was referenced Feb 17, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* Fix loading of styles in static build

* Adds a changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Styles not applied in dev with the static build flag
2 participants