@Layer实用程序已使用,但没有匹配@TailWind Utilities指令
我有一个Laravel 9项目,我想使用尾风CSS。
当我将每个组件的CSS放在某些文件中以将它们分开时,它会导致错误消息,但是如果我将所有内容都放在一起。
body.css 中的错误消息
@layer
使用组件,但没有匹配@TailWind
组件指令。
app.css
@import "tailwind.css";
@import "body.css";
tailwind.css
@tailwind base;
@tailwind components;
@tailwind utilities;
body.css
@layer components {
.body {
@apply bg-sky-100
}
}
webpack.mix.js.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
// require('postcss-import'),
require("tailwindcss/nesting"),
require('autoprefixer'),
])
.webpackConfig({
stats: {
children: true,
},
})
;
tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
],
theme: {
extend: {},
},
plugins: [],
darkMode: 'class',
mode: "jit",
}
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"autoprefixer": "10.4.7",
"axios": "^0.25",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.4"
},
"dependencies": {
"postcss-import": "^14.1.0"
}
}
I have a Laravel 9 project and I want to use the Tailwind CSS.
When I put each component's CSS in some files to separate them, it cause an error message but if I put all together works.
Error message in body.css
@layer
components is used but no matching@tailwind
components directive is present.
app.css
@import "tailwind.css";
@import "body.css";
tailwind.css
@tailwind base;
@tailwind components;
@tailwind utilities;
body.css
@layer components {
.body {
@apply bg-sky-100
}
}
webpack.mix.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
// require('postcss-import'),
require("tailwindcss/nesting"),
require('autoprefixer'),
])
.webpackConfig({
stats: {
children: true,
},
})
;
tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
],
theme: {
extend: {},
},
plugins: [],
darkMode: 'class',
mode: "jit",
}
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"autoprefixer": "10.4.7",
"axios": "^0.25",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.4"
},
"dependencies": {
"postcss-import": "^14.1.0"
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 build noreferrer'> build time intimps 以确保 @>确保 @ @进口是在尾风处理之前处理的。
尾风文档中有一个部分,您可以参考在这里/a>。
但是,您已经在依赖项中拥有
Postcss-import
,应该在webpack.mix.js
仅供参考,这是推荐的订购(在”遇到一些问题:
You need to use Build-time imports to make sure @imports are handled before Tailwind processes them.
There is a section in the Tailwind docs that you can reference here.
However, you already have
postcss-import
in your dependencies, you should uncomment it inwebpack.mix.js
and move it above Tailwind, and you should be good to go.FYI, this is the recommended ordering (referenced in nesting docs) otherwise you may run into some issues:
正如其他人提到的那样,在需要postcss-import插件之前,需要postwindcss v3。但是,从V4开始,此问题不再发生。
从tailwindcss v4开始
直到tailwindcss v3
tailwindlabs/parwindlabs/parwindcss
#5934: @layerer Upities使用,但没有使用,但没有匹配的@tailwind Uniforities指令 - 来自Adamwathan - github- tailwindcss v3As others have mentioned, until TailwindCSS v3, the postcss-import plugin is required. However, from v4 onwards, this issue no longer occurs.
From TailwindCSS v4 onwards
Until TailwindCSS v3
tailwindlabs/tailwindcss
#5934: @layer utilities is used but no matching @tailwind utilities directive is present - answer from adamwathan - GitHub - TailwindCSS v3