Skip to content

Commit a52d499

Browse files
authored
fix: do not use ideal image plugin in dev env (#5540)
* fix: do not use ideal image plugin in dev env * Back to JS
1 parent 452f85b commit a52d499

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export default function (
1414
_context: LoadContext,
1515
options: PluginOptions,
1616
): Plugin<void> {
17-
const isProd = process.env.NODE_ENV === 'production';
18-
1917
return {
2018
name: 'docusaurus-plugin-ideal-image',
2119

@@ -24,6 +22,10 @@ export default function (
2422
},
2523

2624
configureWebpack(_config: Configuration, isServer: boolean) {
25+
if (process.env.NODE_ENV !== 'production') {
26+
return {};
27+
}
28+
2729
return {
2830
mergeStrategy: {
2931
'module.rules': 'prepend',
@@ -38,7 +40,6 @@ export default function (
3840
loader: require.resolve('@docusaurus/responsive-loader'),
3941
options: {
4042
emitFile: !isServer, // don't emit for server-side rendering
41-
disable: !isProd,
4243
// eslint-disable-next-line global-require
4344
adapter: require('@docusaurus/responsive-loader/sharp'),
4445
name: 'assets/ideal-img/[name].[hash:hex:7].[width].[ext]',

packages/docusaurus-plugin-ideal-image/src/theme/IdealImage.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
78
import React from 'react';
89
import IdealImage from '@endiliey/react-ideal-image';
910

1011
function Image(props) {
1112
const {alt, className, img} = props;
13+
14+
// In dev env just use regular img with original file
15+
if (img.default) {
16+
return <img src={img.default} className={className} alt={alt} {...props} />;
17+
}
18+
1219
return (
1320
<IdealImage
1421
{...props}

0 commit comments

Comments
 (0)