我尝试自己在 create-react-app 中设置 JIT,但它似乎没有工作,因为样式没有更新。我正在使用 craco 使用 tailwind css 构建应用程序,并且还添加了 TAILWIND mode=WATCH,因为他们建议使其适用于大多数构建。这是我的配置:
tailwind.config.js
module.exports = {
mode: "jit",
purge: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
colors: {
primary: "#ffa500",
secondary: {
100: "#E2E2D5",
200: "#888883",
},
},
},
},
variants: {
extend: {
opacity: ["disabled"],
},
},
plugins: [],};
package.json 脚本
"scripts": {
"start": " craco start",
"build": "TAILWIND_MODE=watch craco build",
"test": "craco test",
"server": "nodemon ./server/server.js",
"eject": "react-scripts eject"
},
package.json devDependencies
"devDependencies": {
"autoprefixer": "^9.8.6",
"postcss": "^7.0.36",
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.4"
},
如果我能找到任何方法来解决这个问题,我会很高兴。