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

prevent Vite from copying static assets if directory is called public #4214

Merged
merged 2 commits into from Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brave-toys-joke.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Prevent Vite from copying static assets if directory is called "public"
5 changes: 4 additions & 1 deletion packages/kit/src/core/build/build_client.js
Expand Up @@ -89,7 +89,10 @@ export async function build_client({
hydratable: !!config.kit.browser.hydrate
}
})
]
],
// prevent Vite copying the contents of `config.kit.files.assets`,
// if it happens to be 'public' instead of 'static'
publicDir: false
});

print_config_conflicts(conflicts, 'kit.vite.', 'build_client');
Expand Down
3 changes: 3 additions & 0 deletions packages/kit/test/prerendering/options/public/robots.txt
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
4 changes: 4 additions & 0 deletions packages/kit/test/prerendering/options/svelte.config.js
Expand Up @@ -12,6 +12,10 @@ const config = {
}
},

files: {
assets: 'public'
},

paths: {
base: '/path-base',
assets: 'https://cdn.example.com/stuff'
Expand Down
4 changes: 4 additions & 0 deletions packages/kit/test/prerendering/options/test/test.js
Expand Up @@ -27,4 +27,8 @@ test('adds CSP headers via meta tag', () => {
);
});

test('does not copy `public` into `_app`', () => {
assert.ok(!fs.existsSync(`${build}/_app/robots.txt`));
});

test.run();