gpt4 book ai didi

reactjs - React craco tailwind postcss 集成

转载 作者:行者123 更新时间:2023-12-05 06:59:00 30 4
gpt4 key购买 nike

我的项目使用 craco 来启动/构建,我希望集成 tailwind postcss。我已遵循本教程 https://dev.to/ryandunn/how-to-use-tailwind-with-create-react-app-and-postcss-with-no-hassle-2i09但结果,我遇到了这个错误: error

我的配置文件如下所示:

craco.config.js(这看起来像是问题所在,因为我觉得这种风格可能会覆盖下面的 craco 风格,所以它导致了上述错误,但不是 100% 确定如何解决这个问题。)

module.exports = {
style: {
postcss: {
plugins: [
require("tailwindcss")("./tailwind.config.js"),
require("postcss-nested"),
require("autoprefixer"),
],
},
},

craco.config.js full version

postcss.config.js

const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
tailwindcss('./tailwind.js'),
require('autoprefixer')
],
};

tailwind.config.js

module.exports = {
purge: ["./src/**/*.html", "./src/**/*.jsx", "./src/**/*.js", "./src/**/*.tx", "./src/**/*.tsx"],
theme: {
extend: {
screens: {
xs: { max: "400px" },
},
},
},
};

我正在运行应用程序

docker-compose up

有什么修复错误和配置的建议吗?请提供一些代码示例提前致谢

最佳答案

您需要卸载 tailwindcss postcss 和 autoprefixer。然后使用这些特定版本重新安装它们

npm install tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9

我遇到了同样的问题!此链接中有更多信息。 https://tailwindcss.com/docs/installation#post-css-7-compatibility-build

关于reactjs - React craco tailwind postcss 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64485516/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com