question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having trouble with Storybook integration

See original GitHub issue

Hello! I am having trouble getting Windi working with my home-baked Vue 3 ui kit that has a storybook for local development and testing. I am using this vite plugin and my storybook main.js looks like this:

const { join, resolve } = require('path');
const WindiCSS = require('vite-plugin-windicss').default;

module.exports = {
  async viteFinal(config, { configType }) {
    config.resolve.alias = {
      ...config.resolve.alias,
      '@': resolve(__dirname, '../src'),
    };
    config.resolve.modules = [resolve(__dirname, '@', '../src'), 'node_modules'];
    config.plugins = config.plugins ?? [];
    config.plugins.push([
      WindiCSS({
        config: join(__dirname, '..', 'windi.config.ts'),
      }),
    ]);
    config.resolve.dedupe = ['@storybook/client-api'];

    // return the customized config
    return config;
  },
  stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
  addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
  core: {
    builder: 'storybook-builder-vite',
  },
};

However, Windi does not appear to be scanning my Vue components. If I add the windi classes to the windi config whitelist, it will work. So I was hoping somebody could point me in the right direction for one of the two solutions.

  1. Less ideal: Whitelist everything. Is there a regex pattern I could add to the windi.config.ts whitelist to just import everything. And then use purgecss to remove the unused styles when building for production?

  2. Ideal: Get windi scanning my Vue components properly when serving storybook. Obviously this is what I actually want. But it’s been a terribly elusive problem, so I’d happily settle for the former. If it’s an easy patch-fix.

Thank you!

Edit: Spelling errors

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
antfucommented, Oct 20, 2021

Sorry I didn’t get time to look into your repro but glad you figure it out! I guess Storybook somehow should better set Vite’s root to project root instead of their own subfolder otherwise this might also cause other plugins to fail.

Meanwhile, our vite plugin provides an option to set the root explicitly:

     WindiCSS({
        root: dirname(__dirname)
      }),

and maybe then you can remove those workaround

1reaction
antfucommented, Sep 27, 2021

Can you create a minimal reproduction so I might be able to have a closer look?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting tips for Storybook Integration
Here are a few issues and questions you might have while setting up and working with the Storybook Integration and their answers.
Read more >
Frequently Asked Questions - Storybook - JS.ORG
Here are some answers to frequently asked questions. If you have a question, you can ask it by opening an issue on the...
Read more >
Get started with Storybook and Next.js
Integrate Storybook with Next.js in four simple steps. ... Next.js and Storybook have extremely compatible component models.
Read more >
How to use Storybook with ESLint - JS.ORG
Automatically validate stories in your code editor. ... These issues are straightforward to fix but easy to miss.
Read more >
Install Storybook
Troubleshooting · Add the --type react flag to the installation command to set up Storybook manually: npx storybook init --type react · Storybook...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found