{"size": 1027, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "stcjs/stc-css-compress", "max_stars_repo_stars_event_min_datetime": "2016-07-03T11:51:31.000Z", "max_stars_repo_stars_event_max_datetime": "2016-07-03T11:51:31.000Z", "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "stcjs/stc-css-compress", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "stcjs/stc-css-compress", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 17.1166666667, "max_line_length": 80, "alphanum_fraction": 0.6075949367}
import Plugin from 'stc-plugin';

/**
 * default css compress options
 */
const compressOpts = {
  removeComment: true,
  removeLastSemicolon: true, 
  removeEmptySelector: true, 
  overrideSameProperty: true, 
  shortValue: true, 
  mergeProperty: true, 
  sortProperty: true, 
  sortSelector: true, 
  mergeSelector: true, 
  propertyToLower: true 
};

let options = null;

/**
 * compress css class
 */
export default class CssCompressPlugin extends Plugin {
  /**
   * run
   */
  async run(){
    if(!options){
      options = {...compressOpts, ...this.config.tpl, ...this.options};
    }
    let ast = await this.getAst();
    let instance = this.stc.flkit.getFlkitInstance('CssCompress', ast, options);
    return instance.run(true);
  }
  /**
   * update
   */
  update(ast){
    this.setAst(ast);
  }
  /**
   * default include
   */
  static include(){
    return /\.css$/i;
  }
  /**
   * use cluster
   */
  static cluster(){
    return false;
  }
  /**
   * use cache
   */
  static cache(){
    return true;
  }
}