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 SSR static build public file copying. fixes #3016 #3037

Merged
merged 4 commits into from
Apr 11, 2022

Conversation

SteveALee
Copy link
Contributor

Changes

  • When SSR is enabled and it's a static build the copying of public files is broken with sub folders
    • fix is to create subfolders as required

Testing

Test added to static -build.test.js

Docs

none

@changeset-bot
Copy link

changeset-bot bot commented Apr 8, 2022

🦋 Changeset detected

Latest commit: 077b1ed

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 Apr 8, 2022
@SteveALee
Copy link
Contributor Author

I couldn't figure the CI lockfile error. I previously looked for lock file in fixture but did not see one d o I simply added the SSR symblink in node modules.

@SteveALee
Copy link
Contributor Author

SteveALee commented Apr 8, 2022

I meant to say that an alternative is to use something like ncp module but didn't fancy an extra dependency sucking in loads of code addressing edge case and options we don't have. #tradeoffs

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Looks good! Not sure about using npath.dirname with a URL, but I'll let @matthewp weigh in.

packages/astro/src/core/build/static-build.ts Outdated Show resolved Hide resolved
packages/astro/src/core/build/static-build.ts Outdated Show resolved Hide resolved
@SteveALee
Copy link
Contributor Author

natemoo-re yeah i think that would be fine and better fits the rest of the code. I just used what I'd used before in path manipulations

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Nice! Thank you for the PR 👍🏻

@SteveALee
Copy link
Contributor Author

@matthewp So The function "async function ssrMoveAssets(opts: StaticBuildOptions)" would appear to have the same issue. Except - I suspect only the root folder needs to be moved, not all the sub files/folders.

@SteveALee SteveALee changed the title Fix SSR static build public file copying Fix SSR static build public file copying. fixes #3016 Apr 9, 2022
@FredKSchott
Copy link
Member

LGTM!

In the future, try to avoid source files/folders with spaces in the name, it can be a nightmare to type out or copy-paste into the terminal. I'll update for you post-merging the PR.

@FredKSchott FredKSchott merged commit 7b0fbd7 into withastro:main Apr 11, 2022
This was referenced Apr 11, 2022
@SteveALee
Copy link
Contributor Author

@FredKSchott oh gosh, I introduced a filename bug? Sorry. I'm at a loss to how that happened - I usually use kebab case and thought I just copied the existing test file. My only excuse is a new monitor has defaulted to smaller text and I thought I could cope - lol

But thanks for accepting - I'm well chuffed to have contributed. Huzzah!

@FredKSchott
Copy link
Member

No worries! I think you did copy an existing test, which I hadn't realized when I commented. No worries at all :)

SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
…stro#3037)

* Fix SSR static build public file copying

* chore: update lockfile

* remove dirname and use URL constructor

* Cleanup test and actually test what it says it tests

Co-authored-by: Nate Moore <[email protected]>
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.

None yet

4 participants