Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): choose to generate ts config (#10572)
ISSUES CLOSED: #10394
- Loading branch information
Showing
17 changed files
with
209 additions
and
12 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
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
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
28 changes: 28 additions & 0 deletions
28
packages/storybook/src/generators/configuration/project-files-ts/.storybook/main.ts__tmpl__
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,28 @@ | ||
import { rootMain } from '<%= offsetFromRoot %>../.storybook/main'; | ||
import type { StorybookConfig, Options } from '@storybook/core-common'; | ||
|
||
const config: StorybookConfig = { | ||
...rootMain, | ||
<% if (useWebpack5) { %> | ||
core: { ...rootMain.core, builder: 'webpack5' }, | ||
<% } %> | ||
|
||
stories: [ | ||
...rootMain.stories, | ||
'../src/app/**/*.stories.mdx', | ||
'../src/app/**/*.stories.@(js|jsx|ts|tsx)', | ||
], | ||
addons: [...(rootMain.addons || []) <% if(uiFramework === '@storybook/react') { %>, '@nrwl/react/plugins/storybook' <% } %><% if(uiFramework === '@storybook/react-native') { %>, '@storybook/addon-ondevice-actions', '@storybook/addon-ondevice-backgrounds', '@storybook/addon-ondevice-controls', '@storybook/addon-ondevice-notes' <% } %>], | ||
webpackFinal: async (config, { configType }: Options) => { | ||
// apply any global webpack configs that might have been specified in .storybook/main.ts | ||
if (rootMain.webpackFinal) { | ||
config = await rootMain.webpackFinal(config, { configType } as Options); | ||
} | ||
|
||
// add your own webpack tweaks if needed | ||
|
||
return config; | ||
}, | ||
}; | ||
|
||
module.exports = config; |
Empty file.
14 changes: 14 additions & 0 deletions
14
.../storybook/src/generators/configuration/project-files-ts/.storybook/tsconfig.json__tmpl__
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,14 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"emitDecoratorMetadata": true | ||
<% if(uiFramework === '@storybook/react') { %>, "outDir": "" <% } %> | ||
}, | ||
<% if(uiFramework === '@storybook/react') { %>"files": [ | ||
"<%= offsetFromRoot %>../node_modules/@nrwl/react/typings/styled-jsx.d.ts", | ||
"<%= offsetFromRoot %>../node_modules/@nrwl/react/typings/cssmodule.d.ts", | ||
"<%= offsetFromRoot %>../node_modules/@nrwl/react/typings/image.d.ts" | ||
],<% } %> | ||
"exclude": ["../**/*.spec.ts" <% if(uiFramework === '@storybook/react') { %>, "../**/*.spec.js", "../**/*.spec.tsx", "../**/*.spec.jsx"<% } %>], | ||
"include": ["../src/**/*", "*.js", "*.ts" <% if(uiFramework === '@storybook/react-native') { %>, "*.tsx"<% } %>] | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/storybook/src/generators/configuration/root-files-ts/.storybook/main.ts
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,12 @@ | ||
import type { StorybookConfig } from '@storybook/core-common'; | ||
|
||
export const rootMain: StorybookConfig = { | ||
stories: [], | ||
addons: ['@storybook/addon-essentials'], | ||
// webpackFinal: async (config, { configType }) => { | ||
// // Make whatever fine-grained changes you need that should apply to all storybook configs | ||
|
||
// // Return the altered config | ||
// return config; | ||
// }, | ||
}; |
14 changes: 14 additions & 0 deletions
14
packages/storybook/src/generators/configuration/root-files-ts/.storybook/tsconfig.json
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,14 @@ | ||
{ | ||
"extends": "../<%= rootTsConfigPath %>", | ||
"exclude": [ | ||
"../**/*.spec.js", | ||
"../**/*.test.js", | ||
"../**/*.spec.ts", | ||
"../**/*.test.ts", | ||
"../**/*.spec.tsx", | ||
"../**/*.test.tsx", | ||
"../**/*.spec.jsx", | ||
"../**/*.test.jsx" | ||
], | ||
"include": ["../**/*"] | ||
} |
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
1de896f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx.dev