javascript Laravel Mix:Tailwind CSS + PurgeCSS示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Laravel Mix:Tailwind CSS + PurgeCSS示例相关的知识,希望对你有一定的参考价值。

let mix = require("laravel-mix");
let tailwindcss = require("tailwindcss");
let glob = require("glob-all");
let PurgecssPlugin = require("purgecss-webpack-plugin");

/**
 * Custom PurgeCSS Extractor
 * https://github.com/FullHuman/purgecss
 * https://github.com/FullHuman/purgecss-webpack-plugin
 */
class TailwindExtractor {
  static extract(content) {
    return content.match(/[A-z0-9-:\/]+/g);
  }
}

mix.postCss("./src/styles.css", "public/css", [tailwindcss("./tailwind.js")]);
mix.webpackConfig({
  plugins: [
    new PurgecssPlugin({
      paths: glob.sync([
        path.join(__dirname, "resources/views/**/*.blade.php"),
        path.join(__dirname, "resources/assets/js/**/*.vue")
      ]),
      extractors: [
        {
          extractor: TailwindExtractor,
          extensions: ["html", "js", "php", "vue"]
        }
      ]
    })
  ]
});

以上是关于javascript Laravel Mix:Tailwind CSS + PurgeCSS示例的主要内容,如果未能解决你的问题,请参考以下文章

javascript Twitter引导脚本通过laravel-mix

javascript Laravel Mix:Tailwind CSS + PurgeCSS示例

javascript 使用Purgecss与Tailwind和Laravel Mix

Laravel Mix 我无法访问我的 javascript 类

Laravel Mix 未定义 JavaScript 函数

javascript 用于AdonisJS的Laravel Mix + TailwindCSS + PurgeCSS资产管道配置