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

时间:2015-02-26 16:19:05

标签: 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"
     }

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

但是我收到错误,说系统找不到文件,不知道它意味着哪个文件。

我用

安装了它
npm install autoprefixer --save-dev

3 个答案:

答案 0 :(得分:5)

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

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

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

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

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

如果您仍然遇到问题,请告诉我们。

答案 1 :(得分:0)

安装:npm install -g postcss-cli autoprefixer

用法(顺序很重要!):postcss main.css -u autoprefixer -d dist/

答案 2 :(得分:0)

如果使用autoprefixer 10,并且在发布postcss-cli v8之前,只需将autoprefixer降级为^ 9.8.6。

相关问题