Use Autoprefixer in npm without Gulp

Bolko picture Bolko · Feb 26, 2015 · Viewed 11.5k times · Source

Do I need to install all these dependencies and devDependencies to use autoprefixer in node, although I do not use gulp at all?

https://github.com/postcss/autoprefixer/blob/master/package.json

I want to use it in node like this:

     "scripts": {
       "build:css": "autoprefixer -b 'last 2 versions' <assets/styles/main.css | cssmin > dist/main.css"
     }

as described here: http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/

But I get an error saying that the system cannot find a file, don´t know which file it means.

I installed it with

npm install autoprefixer --save-dev

Answer

Jeff Heaton picture Jeff Heaton · Nov 25, 2015

Autoprefixer doesn't run on it's own. It needs to be run as part of postcss-cli like so:

postcss --use autoprefixer *.css -d build/

(from https://github.com/postcss/autoprefixer#cli)

Save-dev postcss-cli and then reformat your build:css to match

postcss --use autoprefixer -b 'last 2 versions' <assets/styles/main.css | cssmin > dist/main.css

Then let us know if you're still having problems.