HBuilder中配置Autoprefixer的方法

一、Autoprefixer是什麼?

Autoprefixer是一個後處理程序,你可以同Sass,Stylus或LESS等預處理器共通使用。它適用於普通的CSS,而你無需關心要爲哪些瀏覽器加前綴,只需使用W3C最新的規範關注於實現。

如書寫屬性:

a{
  display: flex;
}


執行autoprefixer後自動生成相關信息:

a{
  display: -webkit-box;    
  display: -webkit-flex;    
  display: -ms-flexbox;    
  display: flex
}


autoprefixer還可以自動清除過期前綴,如:

a{
  -webkit-border-radius: 5px;
  border-radius: 5px
}


執行autoprefixer後:

a{
  border-radius: 5px
}


二、怎樣引入到HBuilder中?


    1、安裝node.js

         下載安裝方法參考:http://www.runoob.com/nodejs/nodejs-install-setup.html


    2、安裝Autoprefixer

          下載路徑:https://github.com/postcss/autoprefixer

          Windows下(沒有mac,mac下情況不清楚):

          npm install autoprefixer -g


     3 、安裝postcss-cli

            npm install postcss-cli -g


      4、HBuilder中配置

            打開HBuilder,運行-外部工具-外部工具配置,新建外部工具配置,如圖:

            eb666a3a219148266a5ac080dce7bd31.png-wh_

            名稱填寫autoprefixer(這個隨意);

            要執行的命令或文件填寫npm安裝目錄../postcss.cmd;

            工作目錄填寫${project_loc};

            參數填寫-u autoprefixer -o ${resource_loc} ${resource_loc}

            配置完後應用,運行。


       5、HBuilder中使用

            在你的css、sass文件中,右鍵選擇外部工具-autoprefixer(此處爲你新建外部工具時的名稱)等待編譯完成即可




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章