mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat(v2): configureWebpack merge strategy + use file-loader for common asset types (#2994)
* Add some default asset loaders Add webpack merge strategy feature to enable plugins to prepend some webpack configuration (like the ideal image plugin that should override the default image loader) * Add documentation for using assets from markdown * add path prefix for webpack file loader * renaming * document Merge strategies * rename mergeStrategies -> mergeStrategy
This commit is contained in:
parent
a5b2b6056b
commit
8aa6ef47e4
13 changed files with 304 additions and 38 deletions
|
@ -275,6 +275,28 @@ module.exports = function (context, options) {
|
|||
};
|
||||
```
|
||||
|
||||
### Merge strategy
|
||||
|
||||
We merge the Webpack configuration parts of plugins into the global Webpack config using [webpack-merge](https://github.com/survivejs/webpack-merge).
|
||||
|
||||
It is possible to specify the merge strategy. For example, if you want a webpack rule to be prepended instead of appended:
|
||||
|
||||
```js {4-11} title="docusaurus-plugin/src/index.js"
|
||||
module.exports = function (context, options) {
|
||||
return {
|
||||
name: 'custom-docusaurus-plugin',
|
||||
configureWebpack(config, isServer, utils) {
|
||||
return {
|
||||
mergeStrategy: {'module.rules': 'prepend'},
|
||||
module: {rules: [myRuleToPrepend]},
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Read the [webpack-merge strategy doc](https://github.com/survivejs/webpack-merge#merging-with-strategies) for more details.
|
||||
|
||||
## `postBuild(props)`
|
||||
|
||||
Called when a (production) build finishes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue