postcss / postcss-cli

CLI for postcss
Other
836 stars 93 forks source link

autoprefixer not applied to input file outside of pwd #423

Closed macacme closed 2 years ago

macacme commented 2 years ago

description

When using postcss-cli with an input file that resides outside of the current directory, autoprefixer (10.4.2) is not applied. I have experienced this issue with versions 8.3.1 and 9.1.0.

failing command

postcss --verbose --no-map -c postcss.config.js -r /path/to/app.css

succeeding command

postcss --verbose --no-map -c postcss.config.js -r ./app.css

postcss.config.js

'use strict'

module.exports = (ctx) => ({
  plugins: {
    autoprefixer: {}
  }
})
RyanZim commented 2 years ago

You're not using the -c option correctly. By default, it searches for postcss.config.js in the same and parent directories of the input files. This is why it doesn't pick it up when you use another path. To make this work, you need to pass to -c the directory to look for postcss.config.js in. Try this:

postcss --verbose --no-map -c . -r /path/to/app.css

macacme commented 2 years ago

Thank you for the quick reply, Ryan! I have learnt a lesson. :)