sapphi-red / vite-plugin-static-copy

rollup-plugin-copy with dev server support.
MIT License
285 stars 29 forks source link

Sporadic writeBundle errors #130

Open klaemo opened 5 days ago

klaemo commented 5 days ago

Hey there, I'm copying a bunch of files in my outDir and keep getting sporadic errors. They are rather random, so I don't know how to reproduce them. Looks like a race condition maybe?

Here are the relevant parts of my vite config:

{
    publicDir: './src/assets/_global',
    plugins: [viteStaticCopy({ targets: [{ src: `./src/assets/${publication}/*`, dest: './' }] })],
    build: {
      outDir: `./dist/${publication}`,
    }
}

Example errors:

[[vite-plugin-static-copy:build] ENOENT: no such file or directory, chmod '/Users/clemens.stolle/dev/thing/packages/templates/dist/xxxxx/fallbacks/image-fallback-default.png'
Error: ENOENT: no such file or directory, chmod '/Users/clemens.stolle/dev/thing/packages/templates/dist/xxxxx/fallbacks/image-fallback-default.png'] {
  errno: -2,
  code: 'PLUGIN_ERROR',
  syscall: 'chmod',
  path: '/Users/clemens.stolle/dev/thing/packages/templates/dist/xxxxx/fallbacks/image-fallback-default.png',
  pluginCode: 'ENOENT',
  plugin: 'vite-plugin-static-copy:build',
  hook: 'writeBundle'
}
[[vite-plugin-static-copy:build] EEXIST: file already exists, mkdir '/Users/clemens.stolle/dev/thing/packages/templates/dist/xxxxx/fallbacks'
Error: EEXIST: file already exists, mkdir '/Users/clemens.stolle/dev/thing/packages/templates/dist/xxxxx/fallbacks'] {
  errno: -17,
  code: 'PLUGIN_ERROR',
  syscall: 'mkdir',
  path: '/Users/clemens.stolle/dev/thing/packages/templates/dist/xxxxx/fallbacks',
  pluginCode: 'EEXIST',
  plugin: 'vite-plugin-static-copy:build',
  hook: 'writeBundle'
}
Node.js v20.18.0
vite: 5.4.9
vite-plugin-static-copy: 2.0.0
sapphi-red commented 4 days ago

I need a reproduction to check this.