How to add PostCSS plugins?

Recommended Method

If present, rename or delete the postcss.config.js in your project directory. Then, in your nuxt.config.js file add the following:

  1. export default {
  2. build: {
  3. postcss: {
  4. // Add plugin names as key and arguments as value
  5. // Install them before as dependencies with npm or yarn
  6. plugins: {
  7. // Disable a plugin by passing false as value
  8. 'postcss-url': false,
  9. 'postcss-nested': {},
  10. 'postcss-responsive-type': {},
  11. 'postcss-hexrgba': {}
  12. },
  13. preset: {
  14. // Change the postcss-preset-env settings
  15. autoprefixer: {
  16. grid: true
  17. }
  18. }
  19. }
  20. }
  21. }

Legacy Method

⚠️ Warning: This is deprecated.

Use postcss.config.js, for example:

  1. const join = require('path').join
  2. const tailwindJS = join(__dirname, 'tailwind.js')
  3. module.exports = {
  4. plugins: [require('tailwindcss')(tailwindJS), require('autoprefixer')]
  5. }