Skip to content

Commit

Permalink
Merge pull request #15529 from storybookjs/docs/document-webpack-inst…
Browse files Browse the repository at this point in the history
…ance

Document webpack instance in presets
  • Loading branch information
shilman committed Jul 12, 2021
2 parents 90895b2 + 7dc255b commit e4e32bb
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 e4e32bb

Please sign in to comment.