【问题标题】:How can I keep/retain CSS comments in the Tailwind CSS build output?如何在 Tailwind CSS 构建输出中保留/保留 CSS 注释?
【发布时间】:2022-02-19 04:50:14
【问题描述】:

我正在为WordPress写一个主题,它需要在CSS文件中的cmets如下:

/*
Theme Name: XX
Theme URI: http://wordpress.org/themes/xxtheme
Author: X team
Author URI: http://xx.org/
Description: X theme.
Version: 1.1
Text Domain: Xdomain
*/

每当我编译 Tailwind CSS 时,style.css 的全部内容都会被替换。有没有一种简单的方法来保留 CSS 文件的一部分? 我正在使用以下命令来构建:

npx tailwindcss -i css/tailwind.css -o style.css

【问题讨论】:

    标签: wordpress tailwind-css npx


    【解决方案1】:

    您可以尝试使用 https://purgecss.com/safelisting.html 将 cmets 列入安全列表。

    我认为您在构建过程中使用了 purgecss,但您尚未粘贴 Tailwind CSS 或 Webpack 配置。

    【讨论】:

      【解决方案2】:

      这是对我有用的解决方案:

      我使用了Tailwind CSS documentation 中提到的 PostCSS 方法,然后在 main.css(即 CSS 文件夹)文件的顶部添加了 cmets。所以当我编译时(使用

      npm 运行开发

      ) cmets 复制到输出文件的 CSS。 package.json“scripts”标签如下:

      “脚本”:{ "dev": "postcss css/main.css -o style.css" }

      【讨论】:

        猜你喜欢
        • 2019-04-17
        • 1970-01-01
        • 1970-01-01
        • 2022-07-28
        • 1970-01-01
        • 2021-01-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多