Skip to content

Commit 03753cb

Browse files
rafhrafhsilverwind
authored
enable tailwind nesting (#29746)
Currently, if you implement native CSS nesting within a Vue component a warning will appear in the terminal. It states `Nested CSS was detected, but CSS nesting has not been configured correctly. Please enable a CSS nesting plugin *before* Tailwind in your configuration.` To fix this error we need to enable the built-in [tailwinds nesting config](https://tailwindcss.com/docs/using-with-preprocessors#nesting). Example code to trigger the warning within a vue component: ```CSS <style> .example { &:hover, &:focus-visible { color: var(--color-text); } & svg { margin-right: 0.78rem; } } </style> ``` --------- Co-authored-by: rafh <[email protected]> Co-authored-by: silverwind <[email protected]>
1 parent 487ac9b commit 03753cb

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

package-lock.json

Lines changed: 48 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"pdfobject": "2.3.0",
4343
"postcss": "8.4.35",
4444
"postcss-loader": "8.1.1",
45+
"postcss-nesting": "12.1.0",
4546
"pretty-ms": "9.0.0",
4647
"sortablejs": "1.15.2",
4748
"swagger-ui-dist": "5.11.8",

webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {readFileSync} from 'node:fs';
1313
import {env} from 'node:process';
1414
import tailwindcss from 'tailwindcss';
1515
import tailwindConfig from './tailwind.config.js';
16+
import tailwindcssNesting from 'tailwindcss/nesting/index.js';
17+
import postcssNesting from 'postcss-nesting';
1618

1719
const {EsbuildPlugin} = EsBuildLoader;
1820
const {SourceMapDevToolPlugin, DefinePlugin} = webpack;
@@ -145,14 +147,18 @@ export default {
145147
sourceMap: sourceMaps === 'true',
146148
url: {filter: filterCssImport},
147149
import: {filter: filterCssImport},
150+
importLoaders: 1,
148151
},
149152
},
150153
{
151154
loader: 'postcss-loader',
152155
options: {
153156
postcssOptions: {
154157
map: false, // https://github.com/postcss/postcss/issues/1914
155-
plugins: [tailwindcss(tailwindConfig)],
158+
plugins: [
159+
tailwindcssNesting(postcssNesting({edition: '2024-02'})),
160+
tailwindcss(tailwindConfig),
161+
],
156162
},
157163
},
158164
}

0 commit comments

Comments
 (0)