parcel-bundler / lightningcss

An extremely fast CSS parser, transformer, bundler, and minifier written in Rust.
https://lightningcss.dev
Mozilla Public License 2.0
6.27k stars 175 forks source link

Resolver can't import stylesheets from URLs #555

Open WillsonSmith opened 1 year ago

WillsonSmith commented 1 year ago

Possibly related to https://github.com/parcel-bundler/lightningcss/issues/479

I'm attempting to import a Google fonts stylesheet with the following

@import url('https://fonts.googleapis.com/css2?family=Lilita+One&display=swap');

The bundler throws with

SyntaxError: No such file or directory (os error 2)
...
loc: { line: 1, column: 1 },
data: 'ResolverError'

I'm using bundle to bundle this file.

Expected result: Imports from URLs should probably remain as urls and not bundle the code.

Version:

"lightningcss": "^1.21.5"
etdr commented 1 year ago

I can't find any documentation to tell if this is like, intended behavior or not. Should I not be using @import url(...) to load (e.g.) fonts from a CDN anyway?

julientaq commented 2 months ago

Did someone found a way for this? The only way out i found is to make a local copy of the url i’m calling on the outside.

I would assume that any css called from a http url is most likely to be a cdn content.

I would says: if the import is local, bundle it, otherwise keep it as it is. Would that be an acceptable behavior?