next.js - Tailwind 的 JIT 模式在 Next JS 的本地主机预览中不起作用
问题描述
我正在构建一个 Next JS 网站并使用 JIT 运行 Tailwind。这是我的tailwind.config.js:
module.exports = {
mode: "jit",
purge: ["./pages/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}"],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {},
extend: {},
plugins: [],
};
问题是每次我编写新代码时都必须重新启动服务器并运行“npm run dev”,因为它没有更新我在 http://localhost:3000/ 上的 CSS。
当我运行我的服务器时,我也会收到警告:
warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
有什么想法可能导致这种情况吗?谢谢!
解决方案
由于 JIT 模式通过扫描模板文件按需生成 CSS,因此在tailwind.config.js文件中使用所有模板路径配置清除选项至关重要,否则,您的 CSS 将为空。用以下内容替换您的清除条目:
purge: ["./public/**/*.html", "./src/**/*.{js,jsx,ts,tsx,vue}"],
推荐阅读
- python - 如何使用 ezsheets API for Google Sheets 冻结一行?
- html - 为什么我的徽标没有缩放/调整 html/css 的大小?
- android - 如何在 Xamarin Android 项目中初始化 Firebase
- firebase-hosting - Firebase 动态链接 - 带有自定义徽标/网站图标的自定义域
- c - 如何打印矩阵中重复的最大元素的位置?
- linux - 搜索数字对时出现 grep 错误
- .net - Kubernetes .NET 应用程序 SocketExceptionFactory+ExtendedSocketException
- c - 使用不同大小的 fo 跳转并在 MPI_Scatter 上发送数据
- php - Laravel reCAPTCHA 未定义索引:127.0.0.1
- python - Scrapy没有得到