Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Autoprefixer in npm without Gulp

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
like image 574
Bolko Avatar asked Feb 26 '15 16:02

Bolko


People also ask

What is autoprefixer NPM?

PostCSS plugin to parse CSS and add vendor prefixes to CSS rules using values from Can I Use. It is recommended by Google and used in Twitter and Taobao.

Is autoprefixer a dev dependency?

The devDependencies of autoprefixer are only needed if you are working on autoprefixer itself (that's why they are devDependencies).

What is autoprefixer Gulp?

Definition of Gulp Autoprefixer. We know that gulp is used to manage the front-end tasks of developers which mean it automates different tasks. Auto prefixer helps us to manage CSS codes; on the other hand, online auto prefixer provides the prefixed CSS codes of websites.

What is PostCSS and autoprefixer?

PostCSS was developed by Andrey Sitnik, the creator of Autoprefixer. It is a Node. js package developed as a tool to transform all of your CSS using JavaScript, thereby achieving much faster build times than other processors.


1 Answers

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.

like image 86
Jeff Heaton Avatar answered Oct 04 '22 13:10

Jeff Heaton