Skip to content

Vite Plugin does not work correctly on Windows #385

Open
@rsi-dwieser

Description

@rsi-dwieser

Steps to reproduce

Take any working vite/pigment configuration and attempt to run vite:serve on windows. It will not work (application does not load)

Current behavior

Vite/Pigment build & serve broken on Windows

Expected behavior

Vite/Pigment build & serve should function on Windows in the same way as Mac, Linux

Context

We have a vite configuration for pigment which runs perfectly on Mac (and presumably Linux) but is entirely broken when run on Windows.

I have traced the issue to this line, which is using an OS-based path.sep.

  const finalTransformLibraries = allLibs.map((lib) => lib.split('/').join(path.sep));

This is causing the transform libraries to be parsed like this.

'@mui\\material',
 '@pigment-css\\react',
 '@mui\\material-pigment-css'

And as such imports of these libraries are not correctly matched and processed during the build process.

Is the expectation that the transform libraries may be a combination of direct paths that need to adjust per OS and npm imports which will not change separators? Or could this separator safely always be "/"?

Your environment

npx @mui/envinfo
  System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 20.17.0 - C:\Program Files (x86)\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files (x86)\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
    Edge: Chromium (127.0.2651.74)
  npmPackages:
    @emotion/react: 11.14.0 => 11.14.0
    @emotion/styled: 11.14.0 => 11.14.0
    @mui/core-downloads-tracker:  6.4.4
    @mui/icons-material: 6.4.4 => 6.4.4
    @mui/material: 6.4.4 => 6.4.4
    @mui/material-pigment-css: 6.4.3 => 6.4.3
    @mui/private-theming:  6.4.3
    @mui/styled-engine:  6.4.3
    @mui/system:  6.4.3
    @mui/types:  7.2.21
    @mui/utils:  6.4.3
    @pigment-css/react: 0.0.30 => 0.0.30
    @pigment-css/vite-plugin: 0.0.28 => 0.0.28
    @types/react: 19.0.8 => 19.0.8
    react: 19.0.0 => 19.0.0
    react-dom: 19.0.0 => 19.0.0
    typescript: 5.7.3 => 5.7.3

Search keywords: windows, vite

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions