I'm working on a Symfony project and using Asset Mapper for the first time. I'm having trouble importing CSS files into a main CSS file. Here’s the situation:
My admin.css file works fine when I add CSS directly to it.
However, when I try to use @import './components/admin/_stat_card.css' inside admin.css, it doesn’t work.
Context
The path seems correct (based on my project structure), but in the browser, I get the following error:
GET https://localhost/assets/styles/components/admin/_stat_card.css net::ERR_ABORTED 404 (Not Found)
Here’s the structure of my assets/ folder:
assets/
├── styles/
│ ├── admin.css
│ └── components/
│ └── admin/
│ └── _stat_card.css
Here is my config/packages/asset_mapper.yaml file:
framework:
asset_mapper:
# The paths to make available to the asset mapper.
paths:
- assets/
missing_import_mode: strict
when@prod:
framework:
asset_mapper:
missing_import_mode: warn
And this is how i use my admin.css in my admin layout template :
<link rel="stylesheet" href="{{ asset('styles/admin.css') }}">
What I’ve checked:
The _stat_card.css file exists in the correct location.
I used the command php bin/console asset-map to confirm that my files are properly mapped.
Despite all this, the error persists, and the imported file is not found.
Questions:
Did I miss something in my configuration?
Does Asset Mapper handle CSS imports (@import) as I expect?