Skip to content

Commit

Permalink
Document webpack instance in presets
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Jul 9, 2021
1 parent 4ddb363 commit 7dc255b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/addons/writing-presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ For example, here is how Storybook automatically adopts `create-react-app`'s con
- `webpackFinal` is applied to the preview config after all user presets have been applied
- `managerWebpack` is applied to the manager config

As of Storybook 6.3, Storybook can run with either `webpack4` or `webpack5` builder. If your addon needs to know which version of Webpack it's running inside, the version and the actual webpack instance itself are both available inside your preset:

```js
// .storybook/main.js

export function webpackFinal(config, { presets }) {
const version = await presets.apply('webpackVersion');
const instance = (await presets.apply('webpackInstance'))?.default;

logger.info(`=> Running in webpack ${version}: ${instance}`);
return config;
}
```
### Manager entries
The addon config `managerEntries` allows you to add addons to Storybook from within a preset. For addons that require custom webpack/babel configuration, it is easier to install the preset, and it will take care of everything.
Expand Down

0 comments on commit 7dc255b

Please sign in to comment.