You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
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: meta/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
To keep the behavior as it was before.
We are an opiniated mainstream doc tool used by a lot of people, many of them are not frontend devs (technical writers, academics).
Asking our users to use custom webpack config, inline file loader syntax or anything makes the upgrade to our next version more complicated.
I'll try to figure out a solution so that moving from non-required to required does not need any change for our users, resolve.roots + default fonts file-loaders might do the trick in this case.
Still think that being able to opt-out of require() with some kind of css inline syntax could be useful, and would be perfectly fine with /* webpackIgnore: true */
Supporting /* webpackIgnore: true */ is not a hard task.
We are an opiniated mainstream doc tool used by a lot of people, many of them are not frontend devs (technical writers, academics).
I know well docusaurus ⭐
But can you clarify what do you mean To keep the behavior as it was before.? Why developers write /fonts/font.ttf? Why do not provide good (resolvable) URL to fonts? Don't forget webpack has resolve.roots, so resolving is not the problem, you can have multiple roots paths
Thank you @eytienne, saved me a lot of time!
For next readers who have had the comments stripped and it wouldn't pass the build, the final solution for me was: /*! /* webpackIgnore: true */
Reacted by Étienne Arabeyre, joao-gabriel-mid and Kévin Berthommier
If anybody else runs into this, particularly if anybody else finds they can't use the /*! /* webpackIgnore: true */ directive comment either to exclude a specific url() from being processed as an import when working with the @wordpress/scripts wp-scripts CLI wrapper for Webpack, another solution: add a url option to the css-loader configuration with a filter function that excludes a specific list of assets.
If you're using a prefab Webpack config you'll need to find the relevant rule in the module.rules list, otherwise you can add the options.url value direction:
cssLoaderRuleReference.options.url={/** * Do not process url() statements for certain files in assets/. * * @param {string} url Path to asset referenced via url(). * @returns {boolean} Whether to process with loader. */filter(url){return!/assets\/(your|pattern|here)/.test(url);},};
Activity
alexander-akait commentedon Feb 6, 2021
What is use case? webpack allows to resolve
/fonts/font.eot, you just need setupresolve.roots(by default is iscontext).The main answer why it should be not resolved?
Sorry but it is broken CSS syntax and will be bad idea.
I agree with:
slorber commentedon Feb 8, 2021
Retro compatibility.
It used to not be resolved before this upgrade (https://github.com/facebook/docusaurus/pull/4081/files) and now it is.
To keep the behavior as it was before.
We are an opiniated mainstream doc tool used by a lot of people, many of them are not frontend devs (technical writers, academics).
Asking our users to use custom webpack config, inline file loader syntax or anything makes the upgrade to our next version more complicated.
I'll try to figure out a solution so that moving from non-required to required does not need any change for our users,
resolve.roots+ default fonts file-loaders might do the trick in this case.Still think that being able to opt-out of require() with some kind of css inline syntax could be useful, and would be perfectly fine with
/* webpackIgnore: true */Thanks
alexander-akait commentedon Feb 8, 2021
Supporting
/* webpackIgnore: true */is not a hard task.I know well
docusaurus⭐But can you clarify what do you mean
To keep the behavior as it was before.? Why developers write/fonts/font.ttf? Why do not provide good (resolvable) URL to fonts? Don't forgetwebpackhasresolve.roots, so resolving is not the problem, you can have multiplerootspathsslorber commentedon Feb 8, 2021
👍
To give full context, I'm working on testing our upcoming canary release on a site that requires LTR support:
After upgrading Docusaurus from
@latestto local symlinks, I saw the site failed to build due to fonts:https://github.com/massoudmaboudi/datagit_v2.docusaurus/blob/master/src/css/custom.css#L196
Errors were related to inability to resolve at those paths + missing file-loaders for fonts (after paths are fixed).
Yet the site worked fine before, as the CSS show unprocessed URLs that are correctly served: https://datagit.ir/styles.10a1b0ec.css
So something has changed, not sure exactly when/how :)
Currently trying to see if the
resolve.roots+ fonts file-loader would let the user upgrade without modifying his CSSalexander-akait commentedon Feb 8, 2021
in v4 we added ability to resolve server relative url and absolute paths, so
/images/image.pngis now consider as resolvableadd fonts loaders + webpack resolve.roots
slorber commentedon Feb 8, 2021
thanks for the info ;)
It seems resolve.roots is working for my usecase, so I'll let you decide if you want to implement the ignore comment
alexander-akait commentedon Feb 9, 2021
Yep, let's do it, but if no problemы right now I will reduce priority of this
[-]Ability for urls to not use require() on a per-url basis[/-][+]Support `/** webpackIgnore: true */`[/+]feat(v2): add fonts loaders + webpack resolve.roots (#4198)
eytienne commentedon Jun 8, 2021
Is this working? Because I have
Error: Can't resolve '/business-specific-image/' in '/.../scss'while having this style:Is my url breaking rules to be resolved? And why the magic comment seems ignored?
alexander-akait commentedon Jun 8, 2021
You need to update
css-loader, please check iteytienne commentedon Jun 8, 2021
Checked, I was in 5.2.4 so up to date with this change and it neither works in 5.2.6.
alexander-akait commentedon Jun 8, 2021
@eytienne please create reproducible test repo, we have strong tests on this
eytienne commentedon Jun 8, 2021
Thank you, I fixed it trying to reproduce. It was because of postcss upstream removing comments with cssnano, the trick with
!works perfectly as mentionned here : https://cssnano.github.io/cssnano/docs/optimisations/discardcomments/antoniandre commentedon Oct 3, 2023
Thank you @eytienne, saved me a lot of time!
For next readers who have had the comments stripped and it wouldn't pass the build, the final solution for me was:
/*! /* webpackIgnore: true */kadamwhite commentedon Aug 20, 2024
If anybody else runs into this, particularly if anybody else finds they can't use the
/*! /* webpackIgnore: true */directive comment either to exclude a specificurl()from being processed as an import when working with the @wordpress/scriptswp-scriptsCLI wrapper for Webpack, another solution: add aurloption to thecss-loaderconfiguration with a filter function that excludes a specific list of assets.If you're using a prefab Webpack config you'll need to find the relevant rule in the
module.ruleslist, otherwise you can add theoptions.urlvalue direction:feat(v2): add fonts loaders + webpack resolve.roots (meta#4198)