Skip to content

Commit 82ee228

Browse files
committed
[devtools] apply tailwind to storybook
1 parent a040e6e commit 82ee228

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/next/.storybook/main.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,37 @@ const config: StorybookConfig = {
3434
},
3535
},
3636
}),
37+
webpackFinal: async (config) => {
38+
// Exclude tailwind.css from all existing CSS rules
39+
config.module?.rules?.forEach((rule) => {
40+
if (
41+
rule &&
42+
typeof rule === 'object' &&
43+
'test' in rule &&
44+
rule.test?.toString().includes('css')
45+
) {
46+
rule.exclude = rule.exclude
47+
? [rule.exclude, /tailwind\.css$/].flat()
48+
: /tailwind\.css$/
49+
}
50+
})
51+
52+
// Add our custom rule for tailwind.css
53+
config.module?.rules?.push({
54+
test: /tailwind\.css$/,
55+
use: [
56+
{
57+
loader: 'style-loader',
58+
options: {
59+
injectType: 'lazyStyleTag',
60+
insert: require.resolve('../next-devtools-inject-tailwind.js'),
61+
},
62+
},
63+
'css-loader',
64+
'postcss-loader',
65+
],
66+
})
67+
return config
68+
},
3769
}
3870
export default config

0 commit comments

Comments
 (0)