Install Purgecss to remove unused CSS

npm install @fullhuman/postcss-purgecss --save-dev

Edit postcss.config.js:

module.exports = {
  plugins: [
    require("tailwindcss"),
    require("autoprefixer"),
    process.env.NODE_ENV === "production" &&
      require("@fullhuman/postcss-purgecss")({
        // add all the html files
        content: ["./src/**/*.vue", "./public/index.html"],
        defaultExtractor: (content) => content.match(/[A-Za-z0-9-_:/]+/g) || [],
      }),
  ],
};

Then run npm run build, you will notice that the generate css file size down from 186602 lines to 600 lines.

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2021-07-11
  • 2022-01-07
猜你喜欢
  • 2021-12-08
  • 2021-07-06
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-01-08
相关资源
相似解决方案