Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/vite/src/node/__tests__/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,29 @@ test('watch rebuild manifest', async (ctx) => {
`)
})

test('copies public directory after building same environment with write false first', async (ctx) => {
const root = resolve(dirname, 'fixtures/public-dir-write-false')
ctx.onTestFinished(() =>
fsp.rm(resolve(root, 'dist'), { recursive: true, force: true }),
)

const builder = await createBuilder({
root,
configFile: false,
logLevel: 'silent',
})

builder.environments.client.config.build.write = false
await builder.build(builder.environments.client)

builder.environments.client.config.build.write = true
await builder.build(builder.environments.client)

await expect(
fsp.readFile(resolve(root, 'dist/favicon.svg'), 'utf-8'),
).resolves.toBe('<svg></svg>')
})

/**
* for each chunks in output1, if there's a chunk in output2 with the same fileName,
* ensure that the chunk code is the same. if not, the chunk hash should have changed.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/prepareOutDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export function prepareOutDirPlugin(): Plugin {
if (rendered.has(this.environment)) {
return
}
rendered.add(this.environment)

const { config } = this.environment
if (config.build.write) {
rendered.add(this.environment)
const { root, build: options } = config
const resolvedOutDirs = getResolvedOutDirs(
root,
Expand Down
Loading