Description
Node's subpath imports syntax exists for a long time now, allowing you to declare aliases to files inside your code base:
{
"imports": {
"#lib/*": "./src/lib/*"
}
}
Sadly, Vite does not handle these inside url('...') statements inside CSS.
Suggested solution
When coming across a url('...') in CSS, and it starts with a hash, check the project's package.json to see if this matches an entry in the imports map and resolves to a file in the project.
This is already done for defined aliases so it would only make sense to apply it to Node imports, too.
Alternative
Keep using relative imports or aliases, both of which are not as nice.
Additional context
No response
Validations
Description
Node's subpath imports syntax exists for a long time now, allowing you to declare aliases to files inside your code base:
{ "imports": { "#lib/*": "./src/lib/*" } }Sadly, Vite does not handle these inside
url('...')statements inside CSS.Suggested solution
When coming across a
url('...')in CSS, and it starts with a hash, check the project's package.json to see if this matches an entry in the imports map and resolves to a file in the project.This is already done for defined aliases so it would only make sense to apply it to Node imports, too.
Alternative
Keep using relative imports or aliases, both of which are not as nice.
Additional context
No response
Validations