Create React App 尚未支持 PostCSS 8,所以您需要安装Tailwind CSS v2.0 PostCSS 7 兼容性版本。 安装和配置 CRACO 由于Create React App 不能让您覆盖原生的 PostCSS 配置,所以我们还需要安装CRACO才能配置 Tailwind。 npminstall@craco/craco 安装完毕后,更新package.
步骤1: 创建 React 应用 如果您还没有设置 React 应用,请使用以下命令创建一个: 代码语言:shell AI代码解释 npx create-react-app my-tailwind-appcdmy-tailwind-app 步骤2: 安装 Tailwind CSS 接下来,使用 npm 安装 Tailwind CSS 及其依赖项: 代码语言:shell AI代码解释 npminstalltailwindcss postcss autoprefi...
Open the./src/index.cssfile that Create React App generates for you by default and use the@tailwinddirective to include Tailwind’sbase,components, andutilitiesstyles, replacing the original file contents: /* ./src/index.css */@tailwindbase;@tailwindcomponents;@tailwindutilities; Tailwind will swa...
+ "build:css-dev": "tailwind build src/styles/index.css -o src/styles/tailwind.css", + "start:js": "react-scripts start", m "start": "npm-run-all build:css-dev start:js", + "build:js": "react-scripts build", m "build": "npm-run-...
对于在 create-react-app 中无法使用 tailwindcss 的问题,主要原因是 create-react-app 不支持在默认配置下直接使用非官方的 CSS 预处理器,包括 tailwindcss。 解决这个问题的方法有两种: 手动配置:可以通过 eject(弹出) create-react-app 的配置文件,然后自己进行配置,使其支持使用 tailwindcss。不过这个方法会使项...
React安装TailwindCSS流程 首先按照官方文档进行安装:https://www.tailwindcss.cn/docs/guides/create-react-app PS:在官方安装的指令改为 npminstall-D tailwindcss@latest postcss@latest autoprefixer@latest 原因是react已经支持postcss 8。 跟随步骤安装完成后npm start产生如下错误...
1. 安装 Tailwind CSS 如果你是从零开始创建一个新的 React 项目,可以使用 create-react-app,如果你已经有一个现有的 React 项目,可以跳过项目创建步骤。 创建新的 React 项目: npx create-react-appmy-app cdmy-project 安装Tailwind CSS 在你的项目目录中运行以下命令来安装 Tailwind CSS 及其所需的依赖项:...
注意:这里--template react指定我们正在使用 Vite 创建一个 React App。 步骤3: 创建项目文件夹后,然后 cd进入项目文件夹。 cd demo-project 运行此命令后,将得到: 注意:将 demo-project 更改为你的项目名称。 步骤4: 现在,下载 TailwindCss 和其他所需的依赖项。 运行以下命令: npm install -D tailwindcss...
1. 安装 Tailwind CSS 如果你是从零开始创建一个新的 React 项目,可以使用 create-react-app,如果你已经有一个现有的 React 项目,可以跳过项目创建步骤。 创建新的 React 项目: npx create-react-appmy-app cdmy-project 安装Tailwind CSS 在你的项目目录中运行以下命令来安装 Tailwind CSS 及其所需的依赖项:...
npx create-react-app --scripts-version=react-scripts-tailwindcss my-appcdmy-app npm start Versions We try to make a version with TailwindCSS every few releases of create-react-app. create-react-app v3.2.0 and Tailwind CSS v1:https://github.com/DemianD/create-react-app-tailwindcss/tree/...