Skip to content

Commit

Permalink
fix(ideal-image): Add issuer to ideal-image Webpack loader (#10910)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Feb 6, 2025
1 parent 3fde4a0 commit cd27927
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/docusaurus-plugin-ideal-image/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
{
Expand Down
11 changes: 11 additions & 0 deletions website/_dogfooding/_docs tests/tests/images/img-tests.css
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
image: ./img/oss_logo.png
---

# Image tests
# Image Tests

import Image from '@theme/IdealImage';

Expand All @@ -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} />
Expand All @@ -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>

0 comments on commit cd27927

Please sign in to comment.