vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.13k stars 6.14k forks source link

CSS file paths in Vite 3 manifest broken on Windows #9295

Closed schonhoff closed 2 years ago

schonhoff commented 2 years ago

Describe the bug

Hello,

after upgrading to vite version 3 and the laravel-plugin matching the version (version 0.5.0), I can't use build on a windows computer because there is an error for the css file not matching the correct form in the manifest.json.

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
            ],
            refresh: true,
        }),
    ],
});

After running this command:

npm run build

Getting this error:

Unable to locate file in Vite manifest: resources/css/app.css.

Someone already reported the issue on the Laravel plugin but the maintainer mentioned it is a vite bug. See for more information: https://github.com/laravel/vite-plugin/issues/101

Thanks for the great tool!

Reproduction

https://github.com/schonhoff/example-app-vite

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 19.12 GB / 31.94 GB
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    npm: 8.13.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.62)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vite: ^3.0.0 => 3.0.2

Laravel Vite Plugin Version: 0.5.0
Laravel Version: 9.21.4
Host operating system: Windows
Web Browser & Version: Chrome - Version 103.0.5060.134 (Offizieller Build) (64-Bit)
Running in Sail / Docker: No
Webserver: WAMP

Used Package Manager

npm

Logs

There is an issue in the manifest.json file. After npm run build the following manifest file was created.

{
  "resources/js/app.js": {
    "file": "assets/app.ab93cf8a.js",
    "src": "resources/js/app.js",
    "isEntry": true
  },
  "resources/css\\app.css": {
    "file": "assets/app.1776c6d9.css",
    "src": "resources/css\\app.css"
  }
}

The errors are the \\ on the app.css.

Validations

TiagoSilvaPereira commented 2 years ago

I had the same problem here: https://github.com/laravel/jetstream/issues/1098#issuecomment-1192025490

timacdonald commented 2 years ago

I've opened a PR to address this. I would absolutely love if someone could test this fix for me as I cannot actually test this fix locally.

See: https://github.com/vitejs/vite/pull/9353

timacdonald commented 2 years ago

FYI this has now been tagged. Please update to v3.0.4

see: https://github.com/vitejs/vite/blob/v3.0.4/packages/vite/CHANGELOG.md