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

Vite does not resolve css url() paths correctly #19058

Closed
7 tasks done
DennisGarding opened this issue Dec 24, 2024 · 6 comments
Closed
7 tasks done

Vite does not resolve css url() paths correctly #19058

DennisGarding opened this issue Dec 24, 2024 · 6 comments

Comments

@DennisGarding
Copy link

Describe the bug

Older issue: #18398

I have the same problem. The browser can not load the font. If i add a dot before the slash or remove the slash, it works

My build config

build: { outDir: fileURLToPath(new URL('./../public/admin', import.meta.url)), target: 'esnext', manifest: true, emptyOutDir: true, minify: true, rollupOptions: { input: fileURLToPath(new URL('./src/main.ts', import.meta.url)), output: { entryFileNames: '[name].js', chunkFileNames: '[name]-[hash].js', assetFileNames: '[name].[ext]', globals: { vue: 'Vue' } } } },

The output

@font-face{ font-display:block; font-family:bootstrap-icons; src:url(/bootstrap-icons.woff2) format("woff2"),url(/bootstrap-icons.woff) format("woff") }

Used in App.vue style

<style> @import "./../node_modules/bootstrap-icons/font/bootstrap-icons.css"; @import "./../node_modules/bootstrap/dist/css/bootstrap.min.css"; ... ...

Reproduction

aaa

Steps to reproduce

No response

System Info

Ubuntu, Chrome

Used Package Manager

npm

Logs

No response

Validations

Copy link

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

@DennisGarding
Copy link
Author

DennisGarding commented Dec 24, 2024

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

Here is the simple repository. For installation, read the README.

https://github.com/DennisGarding/viteConfigReproduction

Is that enough?

@sapphi-red
Copy link
Member

I don't see any problem with this build output as same as #18398. url(/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6) points the ../public/admin/bootstrap-icons.woff2 because Vite expects the output directory to be served under / by default.
Would you expand on what you are expecting here?

@DennisGarding
Copy link
Author

DennisGarding commented Dec 24, 2024

i expect that there is a .(Dot) before the slash.

Like:

url(./bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6)

If you test it in chrome, you will see that it is not working without dot

image

as you see, there are no icons behind the text

This is the Browser source code
image
ChromeDevTools
image

The css file, reached in browser
image

the directory structure in the project
image

if i add a dot manually, it woks

image

@sapphi-red
Copy link
Member

You can set base: './' in that case.

@DennisGarding
Copy link
Author

You can set base: './' in that case.

Ok, that works. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants