简体   繁体   English

PostCSS Autoprefixer 不适用于命令行

[英]PostCSS Autoprefixer not working with command line

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.现在,我目前正在一个项目中工作,在该项目中我必须支持 ie10 的 flexbox,我正在尝试通过终端独立地自动添加一些 CSS 代码。

The project does not support any build tool like gulp or webpack.该项目不支持任何构建工具,如 gulp 或 webpack。

So i have installed postcss and autoprefixer as follows:所以我安装了 postcss 和 autoprefixer 如下:

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

It works for most of my code, but it does not include any prefix for flexbox in ie10.它适用于我的大部分代码,但它不包含 ie10 中 flexbox 的任何前缀。

Am i doing something wrong?难道我做错了什么?

The cli command that you are calling is for postcss-cli-simple not for postcss itself or postcss-cli您正在调用的 cli 命令是针对postcss-cli-simple 的,而不是针对postcss本身或postcss-cli

To use your command you have to install this packages要使用您的命令,您必须安装此软件包

npm install postcss-cli-simple autoprefixer

And then is possible to use this command然后可以使用这个命令

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

This command will convert this:此命令将转换为:

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

Into this成这个

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

Try using .browserslistrc file尝试使用.browserslistrc文件

last 20 versions

Link 关联

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM