在 Netlify 上部署后未应用 Tailwind 样式

Tailwind styles not applied after deployed on Netlify

我正在尝试将我的 react-app 部署到 netlify。但是 tailwindCSS 似乎不起作用。 我没有错误消息或任何东西,所以不知道该走哪条路。部署成功。我正在检查这里和其他论坛的所有答案,但没有解决我的问题。 尝试了不同的构建,并推送了不同的设置,但只是得到了一个没有样式的普通 HTML 页面。

我的package.json

{
  "name": "benji-portfolio",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@craco/craco": "^6.2.0",
    "@headlessui/react": "^1.4.0",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-parallax-tilt": "^1.5.54",
    "react-reveal": "^1.2.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "craco start",
    "build": "craco build",
    "test": "craco test",
    "eject": "react-scripts eject"
  },
  "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": "^9.8.6",
    "postcss": "^7.0.36",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.7"
  }
}

tailwind.config.js

module.exports = {
  purge: [
    '/src/components/About/About.js',
    '/src/components/Contact/Contact.js',
    '/src/components/Navbar/Navbar.js',
    '/src/components/Projects/Projects.js',
    '/src/components/Skills/Skills.js',
    '/public/index.html'
  ],
  darkMode: 'class',
  theme: {
    extend: {
      backgroundImage: (theme) => ({
        'code': "url('/src/components/About/coding-bg-dark.png')",
        'lightcode': "url('/src/components/About/lightcode.png')",
       })
    },
  },
  variants: {
    extend: {
      backgroundImage: ['dark'],
    },
  },
  plugins: [],
}

Netlify 构建设置:

构建命令:craco build

发布目录:public/

完整 github 回购 HERE

所以在尝试了一整天之后。不知何故,我编造了它 运行。我在构建过程中对netlify进行了多次更改,还更改了craco.config.jstailwind.config.js,直到我成功并部署。

对我有用,希望你们中的一些人会发现它有用的是 tailwind.config.js

  1. 我将 module.exports.purge 更改为:
module.exports = {
  purge: [
    "./src/components/**/*.{js,jsx}",
    "./public/index.html",
  ],
...
}
  1. 关于 Netlify 构建设置:

发布目录:build