-
Hi all. I have a monorepo application built with React + Vite + Nx + Tailwind 3. I use Storybook for components sub-project. I've just updated to Tailwind 4, using Vite Tailwind configuration, but it does not work with Storybook, I have this error: [vite] (client) Pre-transform error: Can't resolve 'tailwindcss' in '[path]\libs\shared-components\src' EDIT: I've tried Tailwind 4 in a separate web application and it works fine. Any idea? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 13 replies
-
Hi @mapten |
Beta Was this translation helpful? Give feedback.
-
Hi, I had same (or I guess it´s similar) issue. # package.json
{
"scripts": {
"storybook": "yarn tailwind:watch | yarn storybook:dev",
"storybook:dev": "storybook dev -p 6006",
"storybook:build": "yarn tailwind:build && storybook build",
"tailwind:build": "yarn tailwindcss --cwd ./our_base_path -i ./path_to_input_file/styles.css -o ./path_to_output_file/styles.css",
"tailwind:watch": "yarn tailwind:build --watch",
},
"devDependencies": {
"@tailwindcss/cli": "^4.0.6"
}
} // preview.tsx
import "./path_to_output_file/styles.css" |
Beta Was this translation helpful? Give feedback.
-
Is this is an issue specifically with Edit: For now, my workaround is to use // postcss.config.mjs
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
'@tailwindcss/postcss': {},
},
}
export default config |
Beta Was this translation helpful? Give feedback.
-
The following works for me:
async viteFinal(config) {
// NOTE: for sb 9.1.1, vite 7.1.1, node v22.11.0, on 2005-08-09,
// if we import mergeConfig at the top, it breaks sb on startup, so just use dynamic import here
//
const { default: tailwindcss } = await import("@tailwindcss/vite")
const { mergeConfig } = await import('vite')
return mergeConfig(config, { plugins: [tailwindcss()] })
}
import "../src/tailwind.css"
... |
Beta Was this translation helpful? Give feedback.
Hi, I had same (or I guess it´s similar) issue.
I solved it with
@tailwindcss/cli
. Maybe exists some better solution, but this one works for me.