mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-12 07:42:34 +02:00
refactor(v2): plugins lifecycle (#1299)
* refactor(v2): plugins lifecycle * dont allow duplicate plugin & fix typo
This commit is contained in:
parent
3a7a253db7
commit
73b89658cc
10 changed files with 127 additions and 136 deletions
|
@ -46,27 +46,24 @@ module.exports = async function build(siteDir) {
|
|||
const props = await load(siteDir);
|
||||
|
||||
// Apply user webpack config.
|
||||
const {
|
||||
outDir,
|
||||
siteConfig: {configureWebpack},
|
||||
} = props;
|
||||
const {outDir, plugins} = props;
|
||||
|
||||
const clientConfigObj = createClientConfig(props);
|
||||
// Remove/clean build folders before building bundles.
|
||||
clientConfigObj
|
||||
.plugin('clean')
|
||||
.use(CleanWebpackPlugin, [outDir, {verbose: false, allowExternal: true}]);
|
||||
const serverConfigObj = createServerConfig(props);
|
||||
const clientConfig = applyConfigureWebpack(
|
||||
configureWebpack,
|
||||
clientConfigObj.toConfig(),
|
||||
false,
|
||||
);
|
||||
const serverConfig = applyConfigureWebpack(
|
||||
configureWebpack,
|
||||
serverConfigObj.toConfig(),
|
||||
true,
|
||||
);
|
||||
let serverConfig = createServerConfig(props).toConfig();
|
||||
let clientConfig = clientConfigObj.toConfig();
|
||||
|
||||
// Plugin lifecycle - configureWebpack
|
||||
plugins.forEach(({configureWebpack}) => {
|
||||
if (!configureWebpack) {
|
||||
return;
|
||||
}
|
||||
clientConfig = applyConfigureWebpack(configureWebpack, clientConfig, false);
|
||||
serverConfig = applyConfigureWebpack(configureWebpack, serverConfig, true);
|
||||
});
|
||||
|
||||
// Build the client bundles first.
|
||||
// We cannot run them in parallel because the server needs to know
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue