-
-
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.
Add webpack-to-vite migration guidance
- Loading branch information
Showing
3 changed files
with
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
```js filename=".storybook/main.js" renderer="common" language="js" tabTitle="With Webpack" | ||
export default { | ||
// Replace your-framework with the framework you are using (e.g., react-webpack5, nextjs, angular) | ||
framework: '@storybook/your-framework', | ||
stories: ['../src/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
async webpackFinal(config) { | ||
storybookBaseConfig.module?.rules?.push({ | ||
test: /\.(graphql|gql)$/, | ||
include: [path.resolve('./lib/emails')], | ||
exclude: /node_modules/, | ||
loader: 'graphql-tag/loader', | ||
}); | ||
storybookBaseConfig.module?.rules?.push({ | ||
test: /\.(graphql|gql)$/, | ||
include: [path.resolve('./lib/schema')], | ||
exclude: /node_modules/, | ||
loader: 'raw-loader', | ||
}); | ||
|
||
return config; | ||
}, | ||
}; | ||
``` | ||
```js filename=".storybook/main.js" renderer="common" language="js" tabTitle="With Vite" | ||
export default { | ||
// Replace your-framework with the framework you are using (e.g., react-vite, vue3-vite) | ||
framework: '@storybook/your-framework', | ||
stories: ['../src/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
async viteFinal(config) { | ||
return { | ||
...config, | ||
plugins: [...(config.plugins ?? []), graphql()], | ||
}; | ||
}, | ||
}; | ||
``` | ||
```ts filename=".storybook/main.ts" renderer="common" language="ts" tabTitle="With Webpack" | ||
// Replace your-framework with the framework you are using (e.g., react-webpack5, nextjs, angular) | ||
import type { StorybookConfig } from '@storybook/your-framework'; | ||
|
||
const config: StorybookConfig = { | ||
framework: '@storybook/your-framework', | ||
stories: ['../src/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
async webpackFinal(config) { | ||
storybookBaseConfig.module?.rules?.push({ | ||
test: /\.(graphql|gql)$/, | ||
include: [path.resolve('./lib/emails')], | ||
exclude: /node_modules/, | ||
loader: 'graphql-tag/loader', | ||
}); | ||
storybookBaseConfig.module?.rules?.push({ | ||
test: /\.(graphql|gql)$/, | ||
include: [path.resolve('./lib/schema')], | ||
exclude: /node_modules/, | ||
loader: 'raw-loader', | ||
}); | ||
|
||
return config; | ||
}, | ||
}; | ||
|
||
export default config; | ||
``` | ||
```ts filename=".storybook/main.ts" renderer="common" language="ts" tabTitle="With Vite" | ||
// Replace your-framework with the framework you are using (e.g., react-vite, vue3-vite) | ||
import type { StorybookConfig } from '@storybook/your-framework'; | ||
|
||
const config: StorybookConfig = { | ||
framework: '@storybook/your-framework', | ||
stories: ['../src/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
async viteFinal(config) { | ||
return { | ||
...config, | ||
plugins: [...(config.plugins ?? []), graphql()], | ||
}; | ||
}, | ||
}; | ||
|
||
export default config; | ||
``` |
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