Skip to content

Commit

Permalink
Implement feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun Lloyd committed Apr 19, 2023
1 parent 50f7a37 commit 7316204
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
8 changes: 8 additions & 0 deletions docs/configure/import-css/import-css.js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```js
// .storybook/preview.js
import '../src/styles/global.css';

export default {
parameters: {},
};
```
14 changes: 14 additions & 0 deletions docs/configure/import-css/import-css.ts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```ts
// .storybook/preview.ts

// Replace your-framework with the framework you are using (e.g., react, vue3)
import { Preview } from '@storybook/your-framework';

import '../src/styles/global.css';

const preview: Preview = {
parameters: {},
};

export default preview;
```
10 changes: 3 additions & 7 deletions docs/configure/styling-and-css.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ There are many ways to include CSS in a web application, and correspondingly the

## Importing CSS files

Storybook is pre-configured to recognize imports for css files. To add global CSS for all of your stories, import it in [`.storybook/preview.js`](./overview.md#configure-story-rendering).
Storybook is pre-configured to recognize imports for CSS files. To add global CSS for all your stories, import it in [`.storybook/preview.js`](./overview.md#configure-story-rendering).

```js
// .storybook/preview.js

import '../src/styles/global.css';
```
<FeatureSnippets paths={['configure/import-css/import-css.js.mdx', 'configure/import-css/import-css.ts.mdx']} />

If your component files import their CSS files, this will work too. The noticeable exception to this is if you're using CSS processor tools like Sass or Postcss.

Expand All @@ -22,7 +18,7 @@ If your component files import their CSS files, this will work too. The noticeab

If you're using Vite as your builder, you're covered! Vite supports Sass and PostCSS out-of-the-box 🎉

However, if you're using Webpack and want to use Sass and PostCss, you'll need some extra configuration. We recommend installing [`@storybook/addon-styling`](https://github.com/storybookjs/addon-styling#storybookaddon-styling) to help you configure these tools. Or if you'd prefer, you can customize [Storybook's webpack configuration yourself](../builders/webpack.md#extending-storybooks-webpack-config) to include the appropriate loader(s).
However, if you're using Webpack and want to use Sass and PostCss, you'll need some extra configuration. We recommend installing [`@storybook/addon-styling`](https://github.com/storybookjs/addon-styling#storybookaddon-styling) to help you configure these tools. Or if you'd prefer, you can customize [Storybook's webpack configuration yourself](../builders/webpack.md#override-the-default-configuration) to include the appropriate loader(s).

## CSS-in-JS

Expand Down

0 comments on commit 7316204

Please sign in to comment.