mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-10 14:52:29 +02:00
refactor(theme-classic): add comments to Prism setup; minor refactor (#6391)
This commit is contained in:
parent
7bab9ba46d
commit
1d7827d572
2 changed files with 16 additions and 6 deletions
|
@ -18,13 +18,13 @@ import type {Plugin as PostCssPlugin} from 'postcss';
|
|||
import rtlcss from 'rtlcss';
|
||||
import {readDefaultCodeTranslationMessages} from '@docusaurus/theme-translations';
|
||||
import type {Options} from '@docusaurus/theme-classic';
|
||||
import type webpack from 'webpack';
|
||||
|
||||
const requireFromDocusaurusCore = createRequire(
|
||||
require.resolve('@docusaurus/core/package.json'),
|
||||
);
|
||||
const ContextReplacementPlugin = requireFromDocusaurusCore(
|
||||
'webpack/lib/ContextReplacementPlugin',
|
||||
);
|
||||
const ContextReplacementPlugin: typeof webpack.ContextReplacementPlugin =
|
||||
requireFromDocusaurusCore('webpack/lib/ContextReplacementPlugin');
|
||||
|
||||
// Need to be inlined to prevent dark mode FOUC
|
||||
// Make sure that the 'storageKey' is the same as the one in `/theme/hooks/useTheme.js`
|
||||
|
@ -172,6 +172,9 @@ export default function docusaurusThemeClassic(
|
|||
|
||||
return {
|
||||
plugins: [
|
||||
// This allows better optimization by only bundling those components
|
||||
// that the user actually needs, because the modules are dynamically
|
||||
// required and can't be known during compile time.
|
||||
new ContextReplacementPlugin(
|
||||
/prismjs[\\/]components$/,
|
||||
new RegExp(`^./(${prismLanguages})$`),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue