Skip to content

Commit cd27927

Browse files
authored
fix(ideal-image): Add issuer to ideal-image Webpack loader (#10910)
1 parent 3fde4a0 commit cd27927

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

packages/docusaurus-plugin-ideal-image/src/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export default function pluginIdealImage(
5454
rules: [
5555
{
5656
test: /\.(?:png|jpe?g)$/i,
57+
// We don't want to use the image loader for non-React source code
58+
// ie we don't want to use ideal image loader for CSS files...
59+
// See https://github.com/facebook/docusaurus/issues/10862
60+
issuer: {
61+
and: [/\.(?:tsx?|jsx?|mdx?)$/i],
62+
},
5763
use: [
5864
require.resolve('@docusaurus/lqip-loader'),
5965
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
.dogfood-image-test-css {
9+
background-image: url('./img/oss_logo.png');
10+
background-size: contain;
11+
}

website/_dogfooding/_docs tests/tests/img-tests.mdx website/_dogfooding/_docs tests/tests/images/index.mdx

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
image: ./img/oss_logo.png
33
---
44

5-
# Image tests
5+
# Image Tests
66

77
import Image from '@theme/IdealImage';
88

@@ -14,6 +14,8 @@ export const docusaurusRequire = require('@site/static/img/docusaurus.png');
1414

1515
## Regular images
1616

17+
Those only render in DEV when IdealImage plugin is disabled.
18+
1719
<img src={docusaurusImport} />
1820

1921
<img src={docusaurusRequire.default} />
@@ -23,3 +25,13 @@ export const docusaurusRequire = require('@site/static/img/docusaurus.png');
2325
<Image img={docusaurusImport} />
2426

2527
<Image img={docusaurusRequire} />
28+
29+
## CSS Image
30+
31+
import './img-tests.css';
32+
33+
This should display a div with have a background image
34+
35+
<div
36+
className="dogfood-image-test-css"
37+
style={{border: 'solid', height: '10rem'}}></div>

0 commit comments

Comments
 (0)