在没有Gulp的情况下在npm中使用Autoprefixer

Bol*_*lko 12 node.js npm autoprefixer

我是否需要安装所有这些依赖项和devDependencies才能在节点中使用autoprefixer,尽管我根本不使用gulp?

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

我想在节点中使用它,如下所示:

     "scripts": {
       "build:css": "autoprefixer -b 'last 2 versions' <assets/styles/main.css | cssmin > dist/main.css"
     }
Run Code Online (Sandbox Code Playgroud)

如下所述:http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/

但我得到一个错误,说系统找不到文件,不知道它意味着哪个文件.

我装了它

npm install autoprefixer --save-dev
Run Code Online (Sandbox Code Playgroud)

小智 5

Autoprefixer不会自行运行.它需要作为postcss-cli的一部分运行,如下所示:

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

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

保存-dev postcss-cli然后重新格式化你的构建:css匹配

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

如果你还有问题,请告诉我们.