Respect `build.copyPublicDir` config supplied by user
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
Background
We have a Node.js project where the /static directory is over 1GB in size.
In production, this directory is served using NGINX.
It does not have to be included in the SvelteKit build.
We keep the copy of the files in /static purely for the development server.
Problem
Current version does not respect the user provided build.copyPublicDir config.
// vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
build: { copyPublicDir: false }, // This has no impact.
plugins: [sveltekit()]
});
Workaround
// svelte.config.js
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { randomUUID } from 'node:crypto';
import { env } from 'node:process';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter(),
files: { assets: env.NODE_ENV === 'development' ? 'static' : randomUUID() }
}
};
export default config;
Describe the proposed solution
Respect build.copyPublicDir, similar to the following PR:
Alternatives considered
- Show warning that the
build.copyPublicDiroption has been overridden. - Provide this as an option for the Node.js adapter.
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/kit/src/exports/vite/index.js around the build configuration handling referenced in the issue, then compare the intended behavior with pull request #11688. Confirm how the user-provided build.copyPublicDir value is currently overridden and consider the issue complete when false is respected without requiring the svelte.config.js workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, vite
- Domain
- build-system, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100