GithubHelp home page GithubHelp logo

Comments (6)

jhnns avatar jhnns commented on May 2, 2024

Mhmm, I think the current behavior is correct. CSS does not distinguish between url('file.jpg') and url('./file.jpg'). That's why an empty string '' should be equivalent to './'. Could you describe your use-case? Why do you have an empty url() statement—and how is webpack supposed to handle an empty request?

from loader-utils.

jhnns avatar jhnns commented on May 2, 2024

Ah ok ... this was an error in the first place. What error does webpack report in this case?

from loader-utils.

darrenscerri avatar darrenscerri commented on May 2, 2024

Webpack doesn't report any errors but proceeds to trying to require './ even if it's a JS file.

The original issue was here: facebook/create-react-app#1875. The url('') was a mistake but lead to a very hard-to-find bug.

Webpack currently warns if somebody does a require('') (webpack/webpack#2006).

Maybe we should warn if somebody tries to rewrite ''?

from loader-utils.

jhnns avatar jhnns commented on May 2, 2024

Yeah, I totally see that. While transforming '' to './' is theoretically correct, it is most likely an error.

I thought about throwing an error if an empty url is passed, but that wouldn't be very pleasant to use and it would be a breaking change since the call needs to be wrapped in try/catch.

Maybe it's best to just keep it as it is and let webpack handle it correctly (as you suggested)... not the most beautiful solution 😞, but it would probably work.

from loader-utils.

jhnns avatar jhnns commented on May 2, 2024

@darrenscerri Would you be up to a pull-request? Should be a small change...

from loader-utils.

darrenscerri avatar darrenscerri commented on May 2, 2024

@jhnns Added pull-request

from loader-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.