【问题标题】:vite does not build tailwind cssvite 不构建顺风 css
【发布时间】:2022-01-26 06:06:17
【问题描述】:

我使用npm install -D tailwindcss postcss autoprefixer vite安装了tailwind和其他工具

我使用 npx tailwindcss init -p 创建了 tailwind 和 postcss 配置文件

tailwind.config.js 包含:

module.exports = {
  content: [],
  theme: {
    extend: {},
  },
  plugins: [],
}

postcss.config.js 包含:

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}

我的 CSS 文件存在于 css\tailwind.css 中并包含:

@tailwind base;
@tailwind components;
@tailwind utilities;

CSS 文件使用 <link href="/css/tailwind.css" rel="stylesheet" > 链接到我的 HTMl 页面

当我运行 vite 时,我的应用程序启动时没有构建错误,但没有生成顺风输出。

【问题讨论】:

  • 你真的使用过任何 html 类吗?而且你还需要配置content 属性来告诉 Tailwind 在哪里可以找到带有类的文件

标签: html css tailwind-css vite


【解决方案1】:

你需要调整一些设置,感觉你已经很接近了。

  1. 编辑 Tailwind.config.js

module.exports = {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
  1. 使用“npm run dev”命令启动 Vite 构建脚本。

// Open terminal
npm run dev
  1. (可选)将演示 h1 属性复制到您的索引文件中并进行测试

<h1 class="text-3xl text-blue-700">Testing</h1>

【讨论】:

    猜你喜欢
    • 2021-05-23
    • 2021-05-22
    • 1970-01-01
    • 2021-02-07
    • 2022-12-09
    • 2019-02-20
    • 2021-11-06
    • 2022-08-05
    • 2021-09-20
    相关资源
    最近更新 更多