fix(ideal-image): Add issuer to ideal-image Webpack loader (#10910)

This commit is contained in:
Sébastien Lorber 2025-02-06 14:13:46 +01:00 committed by GitHub
parent 3fde4a0d6a
commit cd2792775e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 1 deletions

View file

@ -54,6 +54,12 @@ export default function pluginIdealImage(
rules: [
{
test: /\.(?:png|jpe?g)$/i,
// We don't want to use the image loader for non-React source code
// ie we don't want to use ideal image loader for CSS files...
// See https://github.com/facebook/docusaurus/issues/10862
issuer: {
and: [/\.(?:tsx?|jsx?|mdx?)$/i],
},
use: [
require.resolve('@docusaurus/lqip-loader'),
{

View file

@ -0,0 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
.dogfood-image-test-css {
background-image: url('./img/oss_logo.png');
background-size: contain;
}

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Before After
Before After

View file

@ -2,7 +2,7 @@
image: ./img/oss_logo.png
---
# Image tests
# Image Tests
import Image from '@theme/IdealImage';
@ -14,6 +14,8 @@ export const docusaurusRequire = require('@site/static/img/docusaurus.png');
## Regular images
Those only render in DEV when IdealImage plugin is disabled.
<img src={docusaurusImport} />
<img src={docusaurusRequire.default} />
@ -23,3 +25,13 @@ export const docusaurusRequire = require('@site/static/img/docusaurus.png');
<Image img={docusaurusImport} />
<Image img={docusaurusRequire} />
## CSS Image
import './img-tests.css';
This should display a div with have a background image
<div
className="dogfood-image-test-css"
style={{border: 'solid', height: '10rem'}}></div>