-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow full control over webpack config.
If a function is returned from the '.storybook/webpack.config.js' then it will kick in 'full-control mode'. The function accepts the baseConfig from storybook and the dev can modify it with full control. This is necessary for more custom webpack configurations.
- Loading branch information
Tim Kindberg
committed
May 4, 2016
1 parent
8d7d6da
commit 96837d5
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Taking Full Control of the Webpack Config | ||
|
||
There are so many so many configuration options. We give a sane config by default, but sometimes you just need to take the wheel. | ||
|
||
> Beware: You will be in full control of the webpack config and could easily break storybook. We have the important bits listed below. | ||
## Full Control Mode | ||
|
||
You'll need to add a `webpack.config.js` file to your config folder (`.storybook/` by default. | ||
|
||
In the `webpack.config.js`, return a **Function** instead of an object. The function will receive our base config. You can make modifications to it or create a brand new one. The function just needs to return a valid webpack config. | ||
|
||
Example: | ||
|
||
```js | ||
// .storybook/webpack.config.js | ||
|
||
// Export a function. Accept the base config as the only param. | ||
module.exports = (storybookBaseConfig) => { | ||
// Make whatever fine-grained changes you need | ||
storybookBaseConfig.module = { ... } | ||
|
||
// Return the altered config | ||
return storybookBaseConfig; | ||
}; | ||
``` | ||
|
||
Pretty straightforward :) | ||
|
||
## Important Parts | ||
|
||
The following sections of the config could break storybook if deleted: | ||
|
||
- `config.entry` | ||
- `config.output` | ||
- `config.plugins[new webpack.HotModuleReplacementPlugin()]` | ||
|
||
You've been warned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters