1、Autoprefixer是什么?css
Autoprefixer是一个后处理程序,你能够同Sass,Stylus或LESS等预处理器共通使用。它适用于普通的CSS,而你无需关心要为哪些浏览器加前缀,只需使用W3C最新的规范关注于实现。html
如书写属性:node
a{ display: flex; }
执行autoprefixer后自动生成相关信息:git
a{ display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex }
autoprefixer还能够自动清除过时前缀,如:github
a{ -webkit-border-radius: 5px; border-radius: 5px }
执行autoprefixer后:web
a{ border-radius: 5px }
2、怎样引入到HBuilder中?npm
一、安装node.js
浏览器
下载安装方法参考:http://www.runoob.com/nodejs/nodejs-install-setup.htmlsass
二、安装Autoprefixerapp
下载路径:https://github.com/postcss/autoprefixer
Windows下(没有mac,mac下状况不清楚):
npm install autoprefixer -g
3 、安装postcss-cli
npm install postcss-cli -g
四、HBuilder中配置
打开HBuilder,运行-外部工具-外部工具配置,新建外部工具配置,如图:
名称填写autoprefixer(这个随意);
要执行的命令或文件填写npm安装目录../postcss.cmd;
工做目录填写${project_loc};
参数填写-u autoprefixer -o ${resource_loc} ${resource_loc}
配置完后应用,运行。
五、HBuilder中使用
在你的css、sass文件中,右键选择外部工具-autoprefixer(此处为你新建外部工具时的名称)等待编译完成便可