Purge CSS 不会从我的 react 应用程序中删除任何未使用的 tailwindcss 类。我认为它没有正确配置。
这是我的 tailwicss-config.js 文件代码:
module.exports = {
purge: ["./public/**/*.html", "./src/**/*.{js,jsx}"],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
colors: {
"primary-dark": "#004A7C",
"secondary-dark": "#005691",
"primary-light": "#E8F1F5",
"secondary-light": "#FAFAFA",
},
gridTemplateColumns: {
"layout-desktop": "18rem 1fr",
},
gridTemplateRows: {
"layout-desktop": "4rem 300px 1fr 4rem",
},
screens: {
xs: "424px",
},
},
},
variants: {
extend: {},
},
plugins: [],
};
package.json 文件:
{
"name": "react-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "npm run watch:css && react-scripts start",
"build": "npm run watch:css && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"watch:css": "postcss src/assets/tailwind.css -o src/assets/output.css"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"autoprefixer": "^10.4.0",
"postcss": "^8.3.11",
"postcss-cli": "^9.0.2",
"tailwindcss": "^2.2.19"
}
}