Skip to content

Commit

Permalink
Merge pull request #15 from idesigncode/storybook
Browse files Browse the repository at this point in the history
Added webpackFinal function for easier setup of required Storybook configuration
  • Loading branch information
idesigncode authored Jun 2, 2023
2 parents 3416964 + f185f74 commit feed04a
Show file tree
Hide file tree
Showing 30 changed files with 990 additions and 457 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ storybook-static/
/formatNodeToJsxString.mjs
/formatValueToString.mjs
/getValueType.mjs
/storybookConfig.mjs
/styles.css
14 changes: 3 additions & 11 deletions .storybook/main.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as packageJson from '../package.json';
import packageJson from '../package.json';
import { webpackFinal } from '../src/storybookConfig.mjs';

export default {
addons: [
Expand Down Expand Up @@ -43,14 +44,5 @@ export default {
return indexer;
});
},
webpackFinal: async (config) => {
config.module.rules.map((rule) => {
if (!rule.type || rule.type !== 'asset/source') {
// ? Ensure any loaders are not run on any 'raw' file imports
rule.resourceQuery = { not: [/raw/] };
}
return rule;
});
return config;
},
webpackFinal,
};
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm i @idesigncode/storybook-tools --save

- ✏️ Write functional "example components" for actual use cases of a component.
- 📑 [PropsTable](https://idesigncode-storybook-tools.netlify.app/?path=/docs/components-propstable--docs): automatically document static & "live-updating" props details.
- 🖥️ [Source](https://idesigncode-storybook-tools.netlify.app/?path=/docs/components-source--docs) & [Raw Imports](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-raw-imports--docs): output production-ready source code.
- 🖥️ [Source](https://idesigncode-storybook-tools.netlify.app/?path=/docs/components-source--docs): output production-ready source code with [Raw Imports](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-webpack--docs#raw-imports) & [Import Path Replacements](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-import-path-replacements--docs).
- 🌙 [DocsContainer](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-docscontainer--docs): dark mode support for Storybook Docs with [storybook-dark-mode](https://github.com/hipstersmoothie/storybook-dark-mode).
- 📸 Image snapshot testing compatible.
- 🎉 Compatible with `MDX` and `CSF` stories.
Expand All @@ -25,6 +25,5 @@ npm i @idesigncode/storybook-tools --save
## Requirements

- See [peer dependencies](package.json)
- The [Raw Imports](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-raw-imports--docs) feature requires the default [Webpack builder](https://storybook.js.org/docs/react/builders/webpack) for Storybook.
- A small amount of [configuration](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-css--docs) for default styles.
- Optional global configuration for using [Import Path Replacements](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-import-path-replacements--docs) with [Source](https://idesigncode-storybook-tools.netlify.app/?path=/docs/components-source--docs).
- The default [Webpack builder](https://storybook.js.org/docs/react/builders/webpack) for Storybook.
- A small amount of configuration for [Webpack](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-webpack--docs) & the [default CSS styles](https://idesigncode-storybook-tools.netlify.app/?path=/docs/configuration-css--docs).
10 changes: 0 additions & 10 deletions __snapshots__/components-source.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,6 @@ exports[`Components/Source Component With Props Raw test 1`] = `
<span class="token keyword">
import
</span>
<span class>
</span>
<span class="token operator">
*
</span>
<span class>
</span>
<span class="token keyword">
as
</span>
<span class>
packageJson
</span>
Expand Down
Binary file modified __snapshots__/configuration-import-path-replacements--env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions __snapshots__/configuration-import-path-replacements.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ exports[`Configuration/Import Path Replacements Env test 1`] = `
<span class="token keyword">
import
</span>
<span class>
</span>
<span class="token operator">
*
</span>
<span class>
</span>
<span class="token keyword">
as
</span>
<span class>
packageJson
</span>
Expand Down
Binary file removed __snapshots__/configuration-raw-imports--example.png
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit feed04a

Please sign in to comment.