13

我是否需要安装所有这些依赖项和 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
4

3 回答 3

5

Autoprefixer 不能自行运行。它需要像这样作为 postcss-cli 的一部分运行:

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

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

Save-dev postcss-cli 然后重新格式化您的 build:css 以匹配

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

然后让我们知道您是否仍有问题。

于 2015-11-25T16:40:55.323 回答
4

安装:npm install -g postcss-cli autoprefixer

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

于 2018-07-05T12:39:44.943 回答
0

在 autoprefixer 10 和 postcss-cli v8 发布之前,只需将 autoprefixer 降级到 ^9.8.6。

于 2020-09-16T06:56:05.740 回答