Skip to content

v4: cross-package ../../ paths produce incorrect output structure #242

@FredrikErikJohansson

Description

@FredrikErikJohansson

Description

In a monorepo using relative ../../ paths to copy files from sibling packages, v4 produces incorrect output paths.

viteStaticCopy({
  targets: [
    { src: '../../packages/ui/locales/*', dest: 'locales' },
  ],
})

Expected: dist/locales/en/ui.json
v3.4.0: Correct
v4.0.0: dist/locales/packages/ui/locales/en/ui.json

The ../../ prefix is stripped by dir.replace(/^(?:\.\.\/)+/, ''), but the remaining packages/ui/locales/en structure gets preserved under dest.

rename: { stripBase: true } over-corrects and places files at dist/ui.json. rename: { stripBase: N } with various values doesn't produce the correct result either.

Workaround: Pin to v3.4.0 (which supports Vite 8).

  • vite-plugin-static-copy: 4.0.0
  • vite: 8.x
  • pnpm workspaces

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions