简体   繁体   English

tailwindcss 配置没有获取我的源文件

[英]tailwindcss config not picking up my source files

I have followed all the steps as described here enter link description here And here is my tailwindcss.config.cjs file.我已按照此处描述的所有步骤进行操作,在此处输入链接描述这是我的tailwindcss.config.cjs文件。

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

What am I doing wrong?我究竟做错了什么?

I came across a subtle nuance with tailwindcss config when defining where tailwind should watch your files.在定义 tailwind 应该在哪里查看文件时,我遇到了 tailwindcss 配置的细微差别。

I had typed the following into my tailwind.config.cjs file:我在 tailwind.config.cjs 文件中输入了以下内容:


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

For a while I couldn't see why tailwind was not picking up my files.有一段时间我不明白为什么 Tailwind 没有接收我的文件。 Upon closer inspection the spaces matter in the value pair of the array.仔细检查后,空格在数组的值对中很重要

Because tailwind uses glob-patterns which are regular expressions, the spaces do matter.因为 tailwind 使用作为正则表达式的 glob-patterns,所以空格很重要。

Intuitive in hindsight but for me a subtle nuance which I hope helps somebody down the line getting started with tailwind setup in new projects.事后看来很直观,但对我来说是一个微妙的细微差别,我希望它能帮助一些人在新项目中开始顺风设置。

Note the correct file without spaces:注意没有空格的正确文件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM