Skip to content

Support /** webpackIgnore: true */ #1256

Description

@slorber
  • Operating System: MacOs
  • Node Version: 14
  • NPM Version: 6
  • webpack Version: 4.44.1
  • css-loader Version: 5.0.1

Feature Proposal

Allow urls to not be converted to require() calls, on a per-url basis.

url('noRequire:/fonts/font.ttf') should just be converted to url('/fonts/font.ttf') without any processing

(noRequire is maybe not a good name but you understand the idea).

I wasn't able to find in a doc to escape on a per-url basis from this url->require conversion behavior

Feature Use Case

I'm the maintainer of https://github.com/facebook/docusaurus and we are doing preparatory work to upgrade to Webpack 5, that will impact thousands of doc sites.

We used css-loader@3, and some users had url("/fonts/font.eot"), and it did not get processed before.

After upgrading to css-loader@5 (PR: facebook/docusaurus#4081)
for some reason an URL that worked before now fails.

url("/fonts/font.eot") used to work, but does not anymore, as it's converted to a require call.

url("!!file-loader!/static/fonts/font.eot") is a good workaround, but I don't feel like we should recommend that to our large user-base, that are not even all frontend developers (we are a documentation tool)

I don't particularly want to disable fully this URL => require() conversion, as I think it's better to let webpack process/hash assets for caching purpose, just having a convenient escape hatch to fallback to no processing at all.

Does it make sense?

Note: it's not convenient for our users to customize the webpack config with site-specific rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions