tailwind 在将自定义颜色添加到 tailwind.config.js 后停止工作。

huangapple go评论62阅读模式
英文:

tailwind stop working after add custom color to tailwind.config.js

问题

你现在的tailwind.config.js文件如下:

module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

portcss文件如下:

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

此外,在package.json中也有tailwind的依赖:

"tailwindcss": "^3.2.4"

你尝试移除自定义的颜色设置,但问题没有得到修复。你还尝试了运行 npm run dev -- --no-cache,但没有帮助。删除 .next 文件夹也没有起作用。即使移动了整个文件夹,问题仍然存在。然后,你删除了所有tailwind配置文件并重新安装它们,但现在一切都混乱了,没有任何tailwind类可用了。

英文:

im using tailwind in my Nextjs project. i decided to add my own color set to tailwind.config.js. then when i go back to my project i saw some tailwind classes for some elements not working and some of them works like before. the codes that should be in global css are there. @tailwind base;
@tailwind components;
@tailwind utilities;

and global css imported in layout. it was working fine whole the time. i changed nothing but just i said earlier. maybe its worth to know that im using experimental feature (appDir) in next.config.js.

its now my tailwind.config.js file:

module.exports = {
  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

portcss file:

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

also has the tailwind in package.json: "tailwindcss": "^3.2.4"

i removed the color set but didnt fixed the problem. i tried npm run dev -- --no-cache
but didnt helped. deleting .next also not worked. even moved the folder but the problem exist. then i deleted all tailwind config files and reinstall them and not everything just messed up. there is no more tailwind classes working now.

答案1

得分: 1

你有尝试添加和

  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
    "./app/**/*.{js,ts,jsx,tsx}"
  ]
英文:

Have You tried adding and

  content: [
    "./pages/**/*.{js,ts,jsx,tsx}",
    "./components/**/*.{js,ts,jsx,tsx}",
    "./app/**/*.{js,ts,jsx,tsx}"
  ]

huangapple
  • 本文由 发表于 2023年2月8日 21:08:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75386268.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定