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:
Sébastien Lorber 2020-07-01 19:06:02 +02:00 committed by GitHub
parent a5b2b6056b
commit 8aa6ef47e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 304 additions and 38 deletions

View file

@ -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.