2016-02-13 81 views
1

使用Brunch作爲我的前端原型的構建工具,我無法設置UnCSS -plugin。我安裝了Bootstrap 4-骨架進行快速設置,除了UnCSS之外,一切都運行平穩。使用早午餐的UnCSS設置

我在brunch build --production上得到的錯誤是error: UnCSS: no stylesheets found。我可以這樣來配置插件:

plugins: 
    sass: 
     options: 
     includePaths: [ 
      'bower_components/bootstrap/scss' 
     ] 
    postcss: 
     processors: [ 
     require('autoprefixer') 
     ] 
    babel: 
     ignore: [ 
     /^(bower_components|vendor)/ 
     ] 
    uncss: 
     options: 
      csspath: 'css/app.css' 
      htmlroot: 'public' 
     files: ['index.html'] 

該項目位於app源文件:在app/assetsindex.htmlmain.scss(進口自舉)和app/stylesheetsstyles.css,並在app/javascriptsapp.js

Brunch將其構建到名爲public的文件夾中,樣式爲public/css/app.css,內容爲public/index.html。問題是,關於UnCSS的配置有什麼不正確?我對它的理解是,它對構建的CSS輸出起作用,在這種情況下,路徑看起來是正確的。

從2014年開始有a question on SO問幾乎相同的事情,但它從來沒有回答。

回答

1

我沒考慮過看GitHub的問題,其中one specifically addressed this。從本質上說,如建議通過@1951FDG

plugins: 
    uncss: 
     options: 
     ignore: [/\.\bactive\b/] 
     ignoreSheets: [/fonts.googleapis/] 
     files: ['public/index.html'] 

忽略:樣本正則表達式忽略 '主動' 類

ignoreSheets:樣本正則表達式忽略谷歌字體

更重要的是,這UnCSS的調用讀取index.html中鏈接的樣式表以查找正確的CSS文件,然後對其進行處理。