-
-
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.
Merge pull request #18187 from storybookjs/vite-builder-docs
Update Vite builder docs a bit
- Loading branch information
Showing
4 changed files
with
31 additions
and
37 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
18 changes: 11 additions & 7 deletions
18
docs/snippets/common/storybook-vite-builder-aliasing.js.mdx
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 |
---|---|---|
@@ -1,20 +1,24 @@ | ||
```js | ||
// .storybook/main.js|ts | ||
// .storybook/main.js|cjs|ts | ||
|
||
const { mergeConfig } = require('vite'); | ||
|
||
module.exports = { | ||
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: ['@storybook/addon-links', '@storybook/addon-essentials'], | ||
core: { | ||
builder: '@storybook/builder-vite', | ||
}, | ||
async viteFinal(config, { configType }) { | ||
// Return the updated configuration | ||
async viteFinal(config) { | ||
// Merge custom configuration into the default config | ||
return mergeConfig(config, { | ||
// Adds a new alias | ||
resolve: { | ||
alias: { exampleAlias: 'something' }, | ||
// Use the same "resolve" configuration as your app | ||
resolve: (await import('../vite.config.js')).default.resolve | ||
// Add dependencies to pre-optimization | ||
optimizeDeps: { | ||
include: ['storybook-dark-mode'], | ||
}, | ||
}); | ||
}, | ||
}; | ||
``` | ||
``` |
12 changes: 4 additions & 8 deletions
12
...ybook-vite-builder-error-optimized.js.mdx → ...torybook-vite-builder-react-docgen.js.mdx
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 |
---|---|---|
@@ -1,18 +1,14 @@ | ||
```js | ||
// .storybook/main.js|ts | ||
// .storybook/main.js | ||
|
||
module.exports = { | ||
stories: ['../stories/**/*.stories.mdx', '../stories/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: ['@storybook/addon-links', '@storybook/addon-essentials'], | ||
core: { | ||
builder: '@storybook/builder-vite', | ||
}, | ||
async viteFinal(config, { configType }) { | ||
config.optimizeDeps.include = [ | ||
...(config.optimizeDeps?.include ?? []), | ||
// Other dependencies go here | ||
]; | ||
return config; | ||
typescript: { | ||
reactDocgen: 'react-docgen', // 👈 react-docgen configured here. | ||
}, | ||
}; | ||
``` | ||
``` |