Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

css background-image url with @ in path is not managed as resource #1995

Open
TiTi opened this issue May 10, 2021 · 7 comments
Open

css background-image url with @ in path is not managed as resource #1995

TiTi opened this issue May 10, 2021 · 7 comments

Comments

@TiTi
Copy link

TiTi commented May 10, 2021

Hello,
One image referenced in the css doesn't have the appropriate path because of an "@" in the image filename 😢.

First i'm using this fusebox configuration (expecting production resources url to starts with /static/resources/):

    resources: {
      resourceFolder: './resources/',
      resourcePublicRoot: '/static/resources',
    }

But I got this unfortunately:
image
One is working, not the other!

The css is imported like so:

import 'leaflet-fullscreen/dist/leaflet.fullscreen.css';

And here are the relevant parts of that file:

.leaflet-control-fullscreen a {
  background:#fff url(fullscreen.png) no-repeat 0 0;
  background-size:26px 52px;
  }

/* ...snip... */

@media
  (-webkit-min-device-pixel-ratio:2),
  (min-resolution:192dpi) {
    .leaflet-control-fullscreen a {
      background-image:url([email protected]);
    }
  }

We can see the filename "[email protected]" is not even randomized compared to other resources fusebox manage.
I tried to remove the '@' (+ add the corresponding file) and everything's working as expected:
image

Unfortunately, this is not a .css i manage but one from a node package: leaflet-fullscreen
Thus a fix would be really helpful to avoid complex shenanigans.

[I'm also having the same issue with esri-leaflet-geocoder npm package and dist\img\[email protected]]

@nchanged
Copy link
Contributor

nchanged commented May 10, 2021 via email

@TiTi
Copy link
Author

TiTi commented May 10, 2021

I have the same issue in development and production modes.
Clearing the cache does not help, I tried.

The '@' is probably breaking a regexp?

@nchanged
Copy link
Contributor

nchanged commented May 10, 2021 via email

@TiTi
Copy link
Author

TiTi commented May 10, 2021

I could.
But this file is from node_modules\leaflet-fullscreen\dist\leaflet.fullscreen.css
So I don't want to edit it.

It's also possible to fix the issue so that fusebox is able to manage files with an '@' in their name ^^

@nchanged
Copy link
Contributor

these usually correspond to variables in stylus (?I) I don't remember which preprocessor exactly.

@TiTi
Copy link
Author

TiTi commented May 10, 2021

My gut tell me we take a fast exit condition here:
https://github.com/fuse-box/fuse-box/blob/master/src/stylesheet/cssResolveURL.ts#L133

@TiTi
Copy link
Author

TiTi commented May 10, 2021

Ok i didn't see what you mean by macro initially, then i found i could do:

    stylesheet: {
      macros: {
        // Fix images not loaded by fusebox because having an '@' inside
        "[email protected]": path.join(__dirname, 'src/css/leaflet/fullscreen2x.png'), // leaflet-fullscreen
        "img/[email protected]": path.join(__dirname, 'src/css/leaflet/search2x.png'), // esri-leaflet-geocoder
        "img/[email protected]": path.join(__dirname, 'src/css/leaflet/loading2x.gif'), // esri-leaflet-geocoder
      }
    }

Which is an acceptable workaround as i don't have too much images with an '@'. This also works:

    stylesheet: {
      macros: {
        // Fix images not loaded by fusebox because having an '@' inside
        "@": ""
      }
    }

(the compilation warnings show you files to generate without '@' in their name as they are missing)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants