From a952f4c626280adddc3872a704bb33ea049b0077 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Thu, 5 Oct 2023 12:56:06 +0200 Subject: [PATCH] Keep existing image folder for md image assets --- packages/docusaurus-mdx-loader/src/loader.ts | 7 ++++--- packages/docusaurus-utils/src/webpackUtils.ts | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/docusaurus-mdx-loader/src/loader.ts b/packages/docusaurus-mdx-loader/src/loader.ts index 328d2f60015b..fab2f63ab9d3 100644 --- a/packages/docusaurus-mdx-loader/src/loader.ts +++ b/packages/docusaurus-mdx-loader/src/loader.ts @@ -28,7 +28,7 @@ import type {LoaderContext} from 'webpack'; type Pluggable = any; // TODO fix this asap const { - loaders: {inlineMarkdownAssetFileLoader}, + loaders: {inlineMarkdownAssetImageFileLoader}, } = getFileLoaderUtils(); export type MDXPlugin = Pluggable; @@ -92,8 +92,9 @@ function createAssetsExportCode(assets: unknown) { if (typeof assetValue === 'string' && assetValue.startsWith('./')) { // TODO do we have other use-cases than image assets? // Probably not worth adding more support, as we want to move to Webpack 5 new asset system (https://github.com/facebook/docusaurus/pull/4708) - const inlineLoader = inlineMarkdownAssetFileLoader; - return `require("${inlineLoader}${escapePath(assetValue)}").default`; + return `require("${inlineMarkdownAssetImageFileLoader}${escapePath( + assetValue, + )}").default`; } return undefined; } diff --git a/packages/docusaurus-utils/src/webpackUtils.ts b/packages/docusaurus-utils/src/webpackUtils.ts index 644d28641fcc..c1195d5764b3 100644 --- a/packages/docusaurus-utils/src/webpackUtils.ts +++ b/packages/docusaurus-utils/src/webpackUtils.ts @@ -13,14 +13,14 @@ import { } from './constants'; import type {RuleSetRule} from 'webpack'; -type AssetFolder = 'images' | 'files' | 'fonts' | 'medias' | 'assets'; +type AssetFolder = 'images' | 'files' | 'fonts' | 'medias'; type FileLoaderUtils = { loaders: { file: (options: {folder: AssetFolder}) => RuleSetRule; url: (options: {folder: AssetFolder}) => RuleSetRule; inlineMarkdownImageFileLoader: string; - inlineMarkdownAssetFileLoader: string; + inlineMarkdownAssetImageFileLoader: string; inlineMarkdownLinkFileLoader: string; }; rules: { @@ -75,9 +75,9 @@ export function getFileLoaderUtils(): FileLoaderUtils { )}?limit=${urlLoaderLimit}&name=${fileLoaderFileName( 'images', )}&fallback=${escapePath(require.resolve('file-loader'))}!`, - inlineMarkdownAssetFileLoader: `!${escapePath( + inlineMarkdownAssetImageFileLoader: `!${escapePath( require.resolve('file-loader'), - )}?name=${fileLoaderFileName('assets')}!`, + )}?name=${fileLoaderFileName('images')}!`, inlineMarkdownLinkFileLoader: `!${escapePath( require.resolve('file-loader'), )}?name=${fileLoaderFileName('files')}!`,