mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
docs: mention configureWebpack devServer return value (#6881)
This commit is contained in:
parent
23a34c1a07
commit
2a7120cc02
2 changed files with 26 additions and 3 deletions
8
packages/docusaurus-types/src/index.d.ts
vendored
8
packages/docusaurus-types/src/index.d.ts
vendored
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue