Skip to content

Commit

Permalink
feat(core): allow plugins to customize/override Webpack devServer con…
Browse files Browse the repository at this point in the history
…fig (#6107)
  • Loading branch information
slorber committed Dec 16, 2021
1 parent 649f18d commit fc0df30
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions packages/docusaurus/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,20 @@ export default async function start(
}
});

const compiler = webpack(config);
if (process.env.E2E_TEST) {
compiler.hooks.done.tap('done', (stats) => {
if (stats.hasErrors()) {
console.log('E2E_TEST: Project has compiler errors.');
process.exit(1);
}
console.log('E2E_TEST: Project can compile.');
process.exit(0);
});
}

// https://webpack.js.org/configuration/dev-server
const devServerConfig: WebpackDevServer.Configuration = {
const defaultDevServerConfig: WebpackDevServer.Configuration = {
hot: cliOptions.hotOnly ? 'only' : true,
liveReload: false,
client: {
Expand Down Expand Up @@ -222,17 +234,10 @@ export default async function start(
},
};

const compiler = webpack(config);
if (process.env.E2E_TEST) {
compiler.hooks.done.tap('done', (stats) => {
if (stats.hasErrors()) {
console.log('E2E_TEST: Project has compiler errors.');
process.exit(1);
}
console.log('E2E_TEST: Project can compile.');
process.exit(0);
});
}
// Allow plugin authors to customize/override devServer config
const devServerConfig: WebpackDevServer.Configuration = merge(
[defaultDevServerConfig, config.devServer].filter(Boolean),
);

const devServer = new WebpackDevServer(devServerConfig, compiler);
devServer.startCallback(() => {
Expand Down

0 comments on commit fc0df30

Please sign in to comment.