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.

hello, is virtual:windi.css generated somewhere ? i wish to use storybook and if i read the doc correctly i need to import windicss as a global css stylesheet in .storybook/preview.js but it can’t find the file

16:21:49 [vite] Internal server error: Failed to resolve import "virtual:windi.css" from ".storybook\preview.js". Does the file exist?
  Plugin: vite:import-analysis
  File: C:/Users/UserName/Desktop/projects/javascript/test-storybook/.storybook/preview.js
  1  |  import 'virtual:windi.css';
     |          ^
  2  |  
  3  |  export const parameters = {
      at formatError (C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:43549:46)
      at TransformContext.error (C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:43545:19)
      at normalizeUrl (C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:45157:26)
      at async TransformContext.transform (C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:45285:57)
      at async Object.transform (C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:43747:30)
      at async transformRequest (C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:59401:29)
      at async C:\Users\UserName\Desktop\projects\javascript\test-storybook\node_modules\vite\dist\node\chunks\dep-5c642f9e.js:59538:32

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
CanRaucommented, Jul 22, 2021

Got it working with storybook-builder-vite

// .storybook/main.js
const path = require("path");
const WindiCSS = require("vite-plugin-windicss").default;

module.exports = {
  stories: [
    "../components/**/*.stories.mdx",
    "../components/**/*.stories.@(js|jsx|ts|tsx)",
  ],
  addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
  core: {
    builder: "storybook-builder-vite",
  },
  async viteFinal(config, { configType }) {
    config.plugins = config.plugins ?? [];
    config.plugins.push(
      WindiCSS({
        config: path.join(__dirname, "..", "windi.config.ts"), // that was my missing piece
      })
    );
    return config;
  },
};

and just for reference

import "virtual:windi.css";

export const parameters = {
  actions: { argTypesRegex: "^on[A-Z].*" },
  controls: {
    matchers: {
      color: /(background|color)$/i,
      date: /Date$/,
    },
  },
};
4reactions
jbrnskcommented, Oct 20, 2021

No problem @harlan-zw! Shortly-after I shared my workaround, antfu (I’ve @-ed him enough on this one) provided the actual best solution to my issue.

Windi allows you to specify the root directory. And then you don’t need my workaround in the windi.config. All it takes is one extra line to what @CanRau shared:

    config.plugins.push(
      WindiCSS({
        config: join(__dirname, '..', 'windi.config.ts'),
        root: dirname(__dirname),
      })
    );
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · storybookjs/storybook - GitHub
Storybook is a frontend workshop for building UI components and pages in isolation. Made for UI development, testing, and documentation. - Issues ......
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 >
The Cruel King and the Great Hero Storybook Edition
Storybook Edition includes: · The Cruel King and the Great Hero GAME · “Adventures of the Great Hero” Hardcover Art Book · “Scores...
Read more >
Storybook.js - DSM Integration : Loading issue - Stack Overflow
They don't support yet the 5.3 configuration file structure. Just delete you main.js file and go back to pre 5.3 config.js file.
Read more >
Disney Toy Story & Mickey Mouse Comic Book Water Rescue ...
Find many great new & used options and get the best deals for Disney Toy Story & Mickey Mouse Comic Book Water Rescue...
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