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

set Vite's publicDir option #5648

Merged
merged 4 commits into from
Jul 21, 2022
Merged

Conversation

benmccann
Copy link
Member

@benmccann benmccann commented Jul 21, 2022

Trying 14c18e3 again, but in a way that will pass the CI this time

This sets the publicDir option, but still uses our own sirv middleware to serve static assets. Having publicDir set though means that assets end up where expected for Vite plugins like vite-plugin-pwa and that they can find where we keep our assets

@changeset-bot
Copy link

changeset-bot bot commented Jul 21, 2022

🦋 Changeset detected

Latest commit: d63510b

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

This PR includes changesets to release 2 packages
Name Type
@sveltejs/adapter-node Patch
@sveltejs/kit 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

Comment on lines 47 to 49
// files in `static`
vite.middlewares.use(scoped(assets, mutable(config.kit.files.assets)));

Copy link
Member

Choose a reason for hiding this comment

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

we can get rid of this — it's covered by the next middleware now that we're using publicDir

Suggested change
// files in `static`
vite.middlewares.use(scoped(assets, mutable(config.kit.files.assets)));

Copy link
Member

Choose a reason for hiding this comment

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

after getting rid of this, there's only one occurrence of mutable (for prerendered dependencies), so perhaps we should inline the sirv call. though we might then need to ensure that prerendered/dependencies always exists, as I think sirv will barf otherwise

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's nicely structured as a separate method. I took a look at inlining it locally and it doesn't feel quite as clean, so if it's all the same I'd probably just leave it as is

benmccann and others added 2 commits July 21, 2022 08:39
Co-authored-by: Rich Harris <hello@rich-harris.dev>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
@Rich-Harris Rich-Harris merged commit 2cdcd14 into sveltejs:master Jul 21, 2022
Rich-Harris added a commit that referenced this pull request Jul 23, 2022
Rich-Harris added a commit that referenced this pull request Jul 23, 2022
* Revert "set Vite's `publicDir` option (#5648)"

This reverts commit 2cdcd14.

* fix prerendering

* ugh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants