Skip to content

BOOK FINDER #1979

@Sneha4281

Description

@Sneha4281

Describe the bug

no bug found

Link to the blitz that caused the error

https://stackblitz.com/edit/vitejs-vite-uhqpxkyj?file=index.html&terminal=dev

Steps to reproduce

Create a new Vite + React project
npm create vite@latest my-app
cd my-app
npm install
npm run dev

Add an image file inside src/assets/
Example:

src/assets/background.png

Open App.css and try to set background using relative path

.App {
text-align: center;
font-family: Arial, sans-serif;
background-image: url('./assets/background.png'); /* attempt */
background-size: cover;
background-position: center;
background-repeat: no-repeat;
min-height: 100vh;
color: white;
}

Run the project

npm run dev

Open http://localhost:5173 in browser.

Observe
The background image does not appear. The console/network tab may even show a 404 error because Vite cannot resolve relative image paths directly from src when used in CSS.

Expected behavior

The background image (background.png) should be applied to the .App component and displayed full-screen, covering the entire viewport. When running the Vite + React project, the image should load without errors, showing behind the text/content as styled in the CSS.

Parity with Local

Screenshots

No response

Platform

Browser name  = Chrome
Full version  = 140.0.0.0
Major version = 140
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 85756903,
  "usedJSHeapSize": 72770819,
  "jsHeapSizeLimit": 2248146944
}
Hash = 96435430

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions