diff --git a/docs/config/build-options.md b/docs/config/build-options.md index b5872e363de973..bcc83899eeb3c7 100644 --- a/docs/config/build-options.md +++ b/docs/config/build-options.md @@ -218,7 +218,6 @@ By default, Vite will empty the `outDir` on build if it is inside project root. ## build.copyPublicDir -- **Experimental:** [Give feedback](https://github.com/vitejs/vite/discussions/13807) - **Type:** `boolean` - **Default:** `true` diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index dfaab8362784c5..a5557b662f2e5a 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -179,7 +179,6 @@ export interface BuildOptions { /** * Copy the public directory to outDir on write. * @default true - * @experimental */ copyPublicDir?: boolean /** diff --git a/playground/resolve/__tests__/resolve.spec.ts b/playground/resolve/__tests__/resolve.spec.ts index 90d02a761258e6..4a753149552bf2 100644 --- a/playground/resolve/__tests__/resolve.spec.ts +++ b/playground/resolve/__tests__/resolve.spec.ts @@ -1,5 +1,7 @@ +import fs from 'node:fs' +import path from 'node:path' import { expect, test } from 'vitest' -import { isBuild, isWindows, page } from '~utils' +import { isBuild, isWindows, page, testDir } from '~utils' test('bom import', async () => { expect(await page.textContent('.utf8-bom')).toMatch('[success]') @@ -199,3 +201,9 @@ test('Resolving slash with imports filed', async () => { test('Resolving from other package with imports field', async () => { expect(await page.textContent('.imports-pkg-slash')).toMatch('[success]') }) + +test.runIf(isBuild)('public dir is not copied', async () => { + expect( + fs.existsSync(path.resolve(testDir, 'dist/should-not-be-copied')), + ).toBe(false) +}) diff --git a/playground/resolve/public/should-not-be-copied b/playground/resolve/public/should-not-be-copied new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/playground/resolve/vite.config.js b/playground/resolve/vite.config.js index f4d923d1a05ae0..b27df23e734eeb 100644 --- a/playground/resolve/vite.config.js +++ b/playground/resolve/vite.config.js @@ -107,4 +107,7 @@ export default defineConfig({ '@vitejs/test-resolve-sharp-dir', ], }, + build: { + copyPublicDir: false, + }, })