docs(v2): update custom webpack configuration snippet (#2139)

* Update custom webpack configuration snippet

Fix #2097

* Update lifecycle-apis.md
This commit is contained in:
Mattia Astorino 2019-12-29 09:38:50 +01:00 committed by Yangshun Tay
parent d82615b94b
commit 7087425485

View file

@ -154,17 +154,22 @@ For example, this plugin below modify the webpack config to transpile `.foo` fil
// docusaurus-plugin/src/index.js
module.exports = function(context, options) {
return {
name: 'docusaurus-plugin',
name: 'custom-docusaurus-plugin',
configureWebpack(config, isServer, utils) {
const {getCacheLoader} = utils;
config.modules.rules.push({
test: /\.foo$/,
use: [getCacheLoader(isServer), 'my-custom-webpack-loader'],
});
return config;
return {
module: {
rules: [
{
test: /\.foo$/,
use: [getCacheLoader(isServer), 'my-custom-webpack-loader']
}
],
},
};
},
};
};
}
```
## postBuild(props)