hirotaka / storybook-addon-nuxt

This add-on makes it easier to set up Storybook in your Nuxt3 project.
78 stars 17 forks source link

Tailwind support? #2

Open danlourenco opened 1 year ago

danlourenco commented 1 year ago

Hi there,

Great job with this addon! Wondering if this has been tested with Tailwind? I've followed whatever documentation I could find on Storybook 7 + Tailwind 3, but I can't get my Tailwind css to actually load in my stories. Any ideas?

prnews-io-tech commented 1 year ago

Just install the following module: @storybook/addon-styling

And push it to your addons section:

addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
    {
      name: '@storybook/addon-styling',
      options: {
        postCss: true,
      },
    },
    'storybook-addon-nuxt'
  ],

And then just import it inside your .storybook/preview.ts import '../assets/css/tailwind.css';

danlourenco commented 1 year ago

@prnews-io I was doing just that, except in my preview.js file, I was importing the following:

import "tailwindcss/tailwind.css";
import "~/assets/css/main.css";

The tailwind.css file does not exist in the assets folder, and also I thought the options/postCss flag was unnecessary as that appears to be specific to webpack builds.

hirotaka commented 1 year ago

Thanks for using the addon, and sorry for the late reply. I just started exploring how to make Tailwindcss available in a simple setup. I will let you know if there are any further improvements.

daniel007enirman commented 1 year ago

@danlourenco any solution did you find ?

daniel007enirman commented 1 year ago

i got solution

  1. Create Seperate post.config.js file
  2. import postcss-import in post.config.js https://github.com/tailwindlabs/tailwindcss/discussions/5934#discussioncomment-4897960
woldtwerk commented 1 year ago

I made a pr https://github.com/hirotaka/storybook-addon-nuxt/pull/23 this merges nuxt postcss config (also tailwind when using the nuxt tailwind addon) into storybook config. You do not need @storybook/addon-styling or a custom postcss.config.js