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

background-image does not work with public images in style with lang set to scss #17507

Closed
poengAlex opened this issue Sep 13, 2024 · 1 comment
Labels
area/cli bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 mode/spa Qv2 🔝 Quasar v2 issues

Comments

@poengAlex
Copy link

What happened?

This will work in development but not when building for production

<template>
	<q-page class="q-pa-md">
		<div class="image-test"></div>
	</q-page>
</template>

<script setup lang="ts">
</script>

<style lang="scss" scoped>
.image-test {
	width: 100%;
	height: 200px;
	background-image: url('test.png'); //image located in public folder
	background-size: cover;
	background-position: right center;
	background-repeat: no-repeat;
}
</style>

What did you expect to happen?

The image should be a part of the assets after the build. NB! When adding background-image: url('test.png'); as a inline style it does work.

Reproduction URL

https://codepen.io/poengAlex/pen/abgxYwO

How to reproduce?

  1. Use sample code
  2. Add test.png in the public folder
  3. Build it
  4. Serve the code
  5. Image is not available

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite), SPA Mode

Platforms/Browsers

Firefox, Chrome, Safari

Quasar info output

No response

Relevant log output

No response

Additional context

No response

@poengAlex poengAlex added kind/bug 🐞 Qv2 🔝 Quasar v2 issues labels Sep 13, 2024
@github-actions github-actions bot added area/cli bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite mode/spa labels Sep 13, 2024
@rstoenescu
Copy link
Member

Hi,

You are requesting features that are supplied by your dev setup (Webpack/Vite/etc). Those have nothing to do with Quasar itself.

However, if you wish to make your code work, then it matters wether you're using vue-router and with which mode (hash or history). And if you are using a public path. Remember that specifying url('test.png') means the browser will request <current_path>/test.png. Furthermore, if you are using vue router & its history mode, it matters if you also have configured your webserver for it correctly. If you still need help, please head to our https://forum.quasar.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 mode/spa Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

2 participants