mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +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;
|
||||
|
||||
if (configurePostCss) {
|
||||
clientConfig = applyConfigurePostCss(configurePostCss, clientConfig);
|
||||
clientConfig = applyConfigurePostCss(
|
||||
configurePostCss.bind(plugin),
|
||||
clientConfig,
|
||||
);
|
||||
}
|
||||
|
||||
if (configureWebpack) {
|
||||
|
|
|
@ -19,12 +19,6 @@ export default async function externalCommand(
|
|||
|
||||
// Plugin Lifecycle - extendCli.
|
||||
plugins.forEach((plugin) => {
|
||||
const {extendCli} = plugin;
|
||||
|
||||
if (!extendCli) {
|
||||
return;
|
||||
}
|
||||
|
||||
extendCli(cli);
|
||||
plugin.extendCli?.(cli);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -146,12 +146,12 @@ export default async function start(
|
|||
const {configureWebpack, configurePostCss} = plugin;
|
||||
|
||||
if (configurePostCss) {
|
||||
config = applyConfigurePostCss(configurePostCss, config);
|
||||
config = applyConfigurePostCss(configurePostCss.bind(plugin), config);
|
||||
}
|
||||
|
||||
if (configureWebpack) {
|
||||
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,
|
||||
false,
|
||||
props.siteConfig.webpack?.jsLoader,
|
||||
|
|
|
@ -51,7 +51,7 @@ export function loadPluginsThemeAliases({
|
|||
plugins: LoadedPlugin[];
|
||||
}): Promise<ThemeAliases> {
|
||||
const pluginThemes: string[] = plugins
|
||||
.map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
|
||||
.map((plugin) => plugin.getThemePath?.())
|
||||
.filter((x): x is string => Boolean(x));
|
||||
const userTheme = path.resolve(siteDir, THEME_PATH);
|
||||
return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue