FullHuman / postcss-purgecss

PostCSS plugin for purgecss
MIT License
91 stars 5 forks source link

doesn't work with VUE #35

Open DJAlejandro opened 5 years ago

DJAlejandro commented 5 years ago

I want CSS tree shaking. Without using VUE it works well by using purgecss-webpack-plugin.

But i want VUE supporting CSS tree shaking,so I choose postcss-purgecss.But STILL DON'T WORK

here is my postcss.config.js

const path = require("path");

module.exports = {
    plugins: [
        require("@fullhuman/postcss-purgecss")({
            content: [
                path.join(__dirname, './src/views/*.vue'),
            ],
        }),
       ....
    ]
};
saulhardman commented 4 years ago

Hi @DJAlejandro, for more information about configuring PostCSS PurgeCSS to work with Vue single file components, take a look at this blog post.

The article is about Nuxt specifically, but it applies to Vue in general. The issue is that PurgeCSS default extractors detect and preserve all styles defined in the <style> block. Excluding those blocks from selector extraction should achieve the outcome you're looking for.