docs: mention configureWebpack devServer return value (#6881)

This commit is contained in:
Joshua Chen 2022-03-09 20:23:38 +08:00 committed by GitHub
parent 23a34c1a07
commit 2a7120cc02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import type {RuleSetRule, Configuration} from 'webpack';
import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack';
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
import type {CommanderStatic} from 'commander';
import type {ParsedUrlQueryInput} from 'querystring';
@ -254,11 +254,13 @@ export interface Plugin<Content = unknown> {
// TODO refactor the configureWebpack API surface: use an object instead of
// multiple params (requires breaking change)
configureWebpack?: (
config: Configuration,
config: WebpackConfiguration,
isServer: boolean,
utils: ConfigureWebpackUtils,
content: Content,
) => Configuration & {mergeStrategy?: ConfigureWebpackFnMergeStrategy};
) => WebpackConfiguration & {
mergeStrategy?: ConfigureWebpackFnMergeStrategy;
};
configurePostCss?: (options: PostCssOptions) => PostCssOptions;
getThemePath?: () => string;
getTypeScriptThemePath?: () => string;

View file

@ -233,6 +233,27 @@ module.exports = function (context, options) {
Read the [webpack-merge strategy doc](https://github.com/survivejs/webpack-merge#merging-with-strategies) for more details.
### Configuring dev server {#configuring-dev-server}
The dev server can be configured through returning a `devServer` field.
```js title="docusaurus-plugin/src/index.js"
module.exports = function (context, options) {
return {
name: 'custom-docusaurus-plugin',
configureWebpack(config, isServer, utils) {
return {
// highlight-start
devServer: {
open: '/docs', // Opens localhost:3000/docs instead of localhost:3000/
},
// highlight-end
};
},
};
};
```
## `configurePostCss(options)` {#configurePostCss}
Modifies [`postcssOptions` of `postcss-loader`](https://webpack.js.org/loaders/postcss-loader/#postcssoptions) during the generation of the client bundle.