PostCSS Autoprefixer不适用于命令行 [英] PostCSS Autoprefixer not working with command line

查看:76
本文介绍了PostCSS Autoprefixer不适用于命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我目前正在一个项目中,我必须支持ie10的flexbox,我试图通过终端独立地为我的CSS代码自动添加前缀.

Right now, I'm currently working in a project in which i have to support flexbox for ie10, I'm trying to autoprefix some of my CSS code independently via terminal.

该项目不支持gulp或webpack等任何构建工具.

The project does not support any build tool like gulp or webpack.

所以我已经安装了postcss和autoprefixer,如下所示:

So i have installed postcss and autoprefixer as follows:

npm install -g postcss autoprefixer

然后我试图像这样自动为单个文件添加前缀:

and then i'm trying to autoprefix a single file like so:

npx postcss --use autoprefixer --autoprefixer.flexbox --autoprefix.browser "> 0%" -o main.css test.css

它适用于我的大多数代码,但在ie10中不包含flexbox的任何前缀.

It works for most of my code, but it does not include any prefix for flexbox in ie10.

我做错什么了吗?

推荐答案

您正在调用的cli命令用于

The cli command that you are calling is for postcss-cli-simple not for postcss itself or postcss-cli

要使用您的命令,您必须安装此软件包

To use your command you have to install this packages

npm install postcss-cli-simple autoprefixer

然后可以使用此命令

./node_modules/.bin/postcss --use autoprefixer --autoprefixer.browsers "ie 10" -o main.css test.pcss

此命令将转换为:

body {
  display: flex;
  flex: 1 0 calc(1vw - 1px);
}

进入

body {
  display: -ms-flexbox;
  display: flex;
  -ms-flex: 1 0 calc(1vw - 1px);
      flex: 1 0 calc(1vw - 1px);
}

这篇关于PostCSS Autoprefixer不适用于命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆