react+vite配置未检测到CSS文件

nlejzf6q  于 2023-01-22  发布在  React
关注(0)|答案(1)|浏览(165)

我用vite创建了一个reactjs项目,但是在我的配置文件和其他文件下面没有检测到css文件。
//Vite.config.js

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
});

//talwind.config.cjs

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./index.html", "./src/**/*.{html,ts,js,jsx,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
};

//package.json

{
  "name": "adminpanelv1",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "dependencies": {
    "@headlessui/react": "^1.7.7",
    "@vitejs/plugin-react": "^3.0.1",
    "@vitejs/plugin-react-refresh": "^1.3.6",
    "axios": "^1.2.2",
    "chart.js": "^4.1.2",
    "react": "^18.2.0",
    "react-chartjs-2": "^5.2.0",
    "react-dom": "^18.2.0",
    "react-i18next": "^12.1.4",
    "react-icons": "^4.7.1",
    "react-modal": "^3.16.1",
    "react-router-dom": "^6.6.2",
    "react-table": "^7.8.0",
    "react-toastify": "^9.1.1",
    "vite-react-css": "^0.0.0"
  },
  "devDependencies": {
    "@types/react": "^18.0.26",
    "@types/react-dom": "^18.0.9",
    "@vitejs/plugin-react-swc": "^3.0.0",
    "autoprefixer": "^10.4.13",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.2.4",
    "vite": "^4.0.0"
  }
}

//index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Admin Panel</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.jsx"></script>
  </body>

现在我正在使用css,但它没有检测到css文件

---Folder-Name: Tabs
 --File:- Tabs.jsx (import "./Tabs.css"; or "../Tabs/Tabj.css")
 --Css File:- Tabs.css

我不知道是什么原因不检测css文件,到处搜索仍然没有得到解决方案。它只是说没有建议

qco9c6ql

qco9c6ql1#

你应该这样写
导入“(路径)您的css. css”;
应用程序或主jsx。注意,css属性将根据您调用jsx的方式而重叠。

相关问题