mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 05:12:31 +02:00
fix: do not use ideal image plugin in dev env (#5540)
* fix: do not use ideal image plugin in dev env * Back to JS
This commit is contained in:
parent
452f85b5a3
commit
a52d499218
2 changed files with 11 additions and 3 deletions
|
@ -14,8 +14,6 @@ export default function (
|
||||||
_context: LoadContext,
|
_context: LoadContext,
|
||||||
options: PluginOptions,
|
options: PluginOptions,
|
||||||
): Plugin<void> {
|
): Plugin<void> {
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'docusaurus-plugin-ideal-image',
|
name: 'docusaurus-plugin-ideal-image',
|
||||||
|
|
||||||
|
@ -24,6 +22,10 @@ export default function (
|
||||||
},
|
},
|
||||||
|
|
||||||
configureWebpack(_config: Configuration, isServer: boolean) {
|
configureWebpack(_config: Configuration, isServer: boolean) {
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mergeStrategy: {
|
mergeStrategy: {
|
||||||
'module.rules': 'prepend',
|
'module.rules': 'prepend',
|
||||||
|
@ -38,7 +40,6 @@ export default function (
|
||||||
loader: require.resolve('@docusaurus/responsive-loader'),
|
loader: require.resolve('@docusaurus/responsive-loader'),
|
||||||
options: {
|
options: {
|
||||||
emitFile: !isServer, // don't emit for server-side rendering
|
emitFile: !isServer, // don't emit for server-side rendering
|
||||||
disable: !isProd,
|
|
||||||
// eslint-disable-next-line global-require
|
// eslint-disable-next-line global-require
|
||||||
adapter: require('@docusaurus/responsive-loader/sharp'),
|
adapter: require('@docusaurus/responsive-loader/sharp'),
|
||||||
name: 'assets/ideal-img/[name].[hash:hex:7].[width].[ext]',
|
name: 'assets/ideal-img/[name].[hash:hex:7].[width].[ext]',
|
||||||
|
|
|
@ -4,11 +4,18 @@
|
||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import IdealImage from '@endiliey/react-ideal-image';
|
import IdealImage from '@endiliey/react-ideal-image';
|
||||||
|
|
||||||
function Image(props) {
|
function Image(props) {
|
||||||
const {alt, className, img} = props;
|
const {alt, className, img} = props;
|
||||||
|
|
||||||
|
// In dev env just use regular img with original file
|
||||||
|
if (img.default) {
|
||||||
|
return <img src={img.default} className={className} alt={alt} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IdealImage
|
<IdealImage
|
||||||
{...props}
|
{...props}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue