mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
fix(core): make plugin lifecycles consistently bound to the plugin instance (#6850)
This commit is contained in:
parent
a756ddb7e1
commit
b2d6e453e3
4 changed files with 8 additions and 11 deletions
|
@ -174,7 +174,10 @@ async function buildLocale({
|
||||||
const {configureWebpack, configurePostCss} = plugin;
|
const {configureWebpack, configurePostCss} = plugin;
|
||||||
|
|
||||||
if (configurePostCss) {
|
if (configurePostCss) {
|
||||||
clientConfig = applyConfigurePostCss(configurePostCss, clientConfig);
|
clientConfig = applyConfigurePostCss(
|
||||||
|
configurePostCss.bind(plugin),
|
||||||
|
clientConfig,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configureWebpack) {
|
if (configureWebpack) {
|
||||||
|
|
|
@ -19,12 +19,6 @@ export default async function externalCommand(
|
||||||
|
|
||||||
// Plugin Lifecycle - extendCli.
|
// Plugin Lifecycle - extendCli.
|
||||||
plugins.forEach((plugin) => {
|
plugins.forEach((plugin) => {
|
||||||
const {extendCli} = plugin;
|
plugin.extendCli?.(cli);
|
||||||
|
|
||||||
if (!extendCli) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
extendCli(cli);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,12 +146,12 @@ export default async function start(
|
||||||
const {configureWebpack, configurePostCss} = plugin;
|
const {configureWebpack, configurePostCss} = plugin;
|
||||||
|
|
||||||
if (configurePostCss) {
|
if (configurePostCss) {
|
||||||
config = applyConfigurePostCss(configurePostCss, config);
|
config = applyConfigurePostCss(configurePostCss.bind(plugin), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configureWebpack) {
|
if (configureWebpack) {
|
||||||
config = applyConfigureWebpack(
|
config = applyConfigureWebpack(
|
||||||
configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`. // TODO remove this implicit api: inject in callback instead
|
configureWebpack.bind(plugin), // The plugin lifecycle may reference `this`.
|
||||||
config,
|
config,
|
||||||
false,
|
false,
|
||||||
props.siteConfig.webpack?.jsLoader,
|
props.siteConfig.webpack?.jsLoader,
|
||||||
|
|
|
@ -51,7 +51,7 @@ export function loadPluginsThemeAliases({
|
||||||
plugins: LoadedPlugin[];
|
plugins: LoadedPlugin[];
|
||||||
}): Promise<ThemeAliases> {
|
}): Promise<ThemeAliases> {
|
||||||
const pluginThemes: string[] = plugins
|
const pluginThemes: string[] = plugins
|
||||||
.map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
|
.map((plugin) => plugin.getThemePath?.())
|
||||||
.filter((x): x is string => Boolean(x));
|
.filter((x): x is string => Boolean(x));
|
||||||
const userTheme = path.resolve(siteDir, THEME_PATH);
|
const userTheme = path.resolve(siteDir, THEME_PATH);
|
||||||
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue