Skip to content

set Vite's publicDir option - #5648

Merged
Rich-Harris merged 4 commits into
sveltejs:masterfrom
benmccann:publicDir2
Jul 21, 2022
Merged

Rich-Harris merged 4 commits into
sveltejs:masterfrom
benmccann:publicDir2

Conversation

@benmccann

@benmccann benmccann commented Jul 21, 2022 •

Copy link
Copy Markdown
Member

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

changeset-bot Bot commented Jul 21, 2022 •

Copy link
Copy Markdown

🦋 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 thread packages/kit/src/vite/preview/index.js Outdated
Comment on lines 47 to 49
// files in `static`
vite.middlewares.use(scoped(assets, mutable(config.kit.files.assets)));

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread packages/kit/src/vite/preview/index.js Resolved
@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

This branch was successfully deployed

2 active deployments
Preview – kit-svelte-dev — d63510b8 Deployed Jul 21, 2022 by vercel[bot]
Preview – kit — d63510b8 Deployed Jul 21, 2022 by vercel[bot]
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