Nil Vila
Nil Vila

Reputation: 59

Use Postcss with Vuepress

I'm trying to use Postcss plugins with my Vuepress custom theme, but I can't get it to work. Vuepress' documentation is extremely vague and anything from postcss-loader works.

Can someone please tell me how to use it?

Upvotes: 2

Views: 852

Answers (1)

Using postcss is fairly easy with Vuepress. You also do not need to add postcss-loader. Vuepress comes with it, as it uses postcss be default. The only thing you need is to pass configuration option. Here are steps tested to work:

Install postcss plugins you want to use (e.g. yarn add postcss-preset-env -D)

In .vuepress/config.js add this:

module.exports = {
    postcss: {
        plugins: [
            require('postcss-preset-env')({/*plugin options*/})
        ]
    }
}

This is enough to have the plugin enabled. More: https://vuepress.vuejs.org/config/#postcss

Upvotes: 2

Related Questions