Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS file from public folder is not loaded correctly #13426

Closed
7 tasks done
andschuetz opened this issue Jun 5, 2023 · 5 comments
Closed
7 tasks done

CSS file from public folder is not loaded correctly #13426

andschuetz opened this issue Jun 5, 2023 · 5 comments

Comments

@andschuetz
Copy link

Describe the bug

The following worked until we recently updated vite from 4.1.4 to 4.3.9.

We have a Vue app with multiple entry points (that is, different HTML files with further references).

One of those entry points uses <link...> to load a CSS file from a public directory, and an SCSS file from the client application's directory, which is dynamically processed. Seemingly, the CSS file from the public directory can no longer be loaded (while the SCSS file can be loaded). When the vue app is opened using vite preview, a white page is displayed.

Interestingly, the error message in the browser console states:

unsupported-f1d329ce.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)

even though no such .js file is supposed to be created.

Changing the CSS file's location to /src/ClientApp/... solves the issue. This step can be reconstructed using the stackblitz repro. For reference: the entry point in question is called unsupported.html.

Another entry point (the main index.html) however has no such issue loading the same CSS file from the public directory. The difference here is, however, that no further SCSS file is directly loaded, but rather a vue file is included which in turn imports an SCSS file.

Reproduction

https://stackblitz.com/edit/vitejs-vite-py4kuh?file=src%2Funsupported.html

Steps to reproduce

run vite build and
vite preview

in the stackblitz repro

System Info

from Stackblitz:

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @vitejs/plugin-vue2: ^2.2.0 => 2.2.0 
    vite: ^4.3.9 => 4.3.9

Used Package Manager

npm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented Jun 5, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@github-actions
Copy link

github-actions bot commented Jun 5, 2023

Hello @andschuetz. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@patak-dev
Copy link
Member

Hey @andschuetz, please update the reproduction or close and create a new issue. The CSS from public seems to be loading ok if you change /public/style/theme_standard.css to /public/style/theme-standard.css. You should also not use /public/ in the <link> tag.
And you should access the page at /unsupported.html: https://stackblitz.com/edit/vitejs-vite-2mzsmr
Please try to remove custom root, public, and server API config from your repro so it is easier for others to check the issue later too. Thanks!

@andschuetz
Copy link
Author

andschuetz commented Jun 6, 2023

Hi @patak-dev, Thanks for your comments and sorry for the wrong paths in the repro.

I have updated the repro (same URL https://stackblitz.com/edit/vitejs-vite-py4kuh?file=src%2Funsupported.html), removed unnecessary config, and also removed the /public/ part of the CSS path in unsupported.html.

The described error still occurs.

@patak-dev
Copy link
Member

patak-dev commented Jun 6, 2023

Thanks @andschuetz. I've created a new issue with a simplified reproduction (no sass) here:

Let's continue tracking it there

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants