function hippyVueCSSLoader(source) {
  const options = getOptions(this);
  const parsed = parseCSS(source, { source: sourceId });

  const majorNodeVersion = parseInt(process.versions.node.split('.')[0], 10);
  const hashType = majorNodeVersion >= 17 ? 'md5' : 'md4';
  const hash = crypto.createHash(hashType);
  const contentHash = hash.update(source).digest('hex');
  sourceId += 1;
  const rulesAst = parsed.stylesheet.rules.filter(n => n.type === 'rule').map(n => ({
    hash: contentHash,
    selectors: n.selectors,
    declarations: n.declarations.map((dec) => {
      let { value } = dec;
      // FIXME: Should have a strict property with colors map.
      if (dec.property && dec.property.toLowerCase().indexOf('color') > -1) {
        value = translateColor(value, options);
      }
      return {
        type: dec.type,
        property: dec.property,
        value,
      };
    }),
  }));
  const code = `(function() {
    if (!global['${GLOBAL_STYLE_NAME}']) {
      global['${GLOBAL_STYLE_NAME}'] = [];
    }
    global['${GLOBAL_STYLE_NAME}'] = global['${GLOBAL_STYLE_NAME}'].concat(${JSON.stringify(rulesAst)});

    if(module.hot) {
      module.hot.dispose(() => {
        console.log('disposeHandlers');
        if(!global['${GLOBAL_DISPOSE_STYLE_NAME}']) {
          global['${GLOBAL_DISPOSE_STYLE_NAME}'] = [];
        }
        global['${GLOBAL_DISPOSE_STYLE_NAME}'] = global['${GLOBAL_DISPOSE_STYLE_NAME}'].concat('${contentHash}');
      })
    }
  })()`;
  return `module.exports=${code}`;
}
/**
 * Convert the CSS text to AST that able to parse by selector parser.
 */
Convert the CSS text to AST that able to parse by selector parser.
Convert the CSS text to AST that able to parse by selector parser .
function hippyVueCSSLoader(source) {
  const options = getOptions(this);
  const parsed = parseCSS(source, { source: sourceId });
  const majorNodeVersion = parseInt(process.versions.node.split('.')[0], 10);
  const hashType = majorNodeVersion >= 17 ? 'md5' : 'md4';
  const hash = crypto.createHash(hashType);
  const contentHash = hash.update(source).digest('hex');
  sourceId += 1;
  const rulesAst = parsed.stylesheet.rules.filter(n => n.type === 'rule').map(n => ({
    hash: contentHash,
    selectors: n.selectors,
    declarations: n.declarations.map((dec) => {
      let { value } = dec;
      if (dec.property && dec.property.toLowerCase().indexOf('color') > -1) {
        value = translateColor(value, options);
      }
      return {
        type: dec.type,
        property: dec.property,
        value,
      };
    }),
  }));
  const code = `(function() {
    if (!global['${GLOBAL_STYLE_NAME}']) {
      global['${GLOBAL_STYLE_NAME}'] = [];
    }
    global['${GLOBAL_STYLE_NAME}'] = global['${GLOBAL_STYLE_NAME}'].concat(${JSON.stringify(rulesAst)});
    if(module.hot) {
      module.hot.dispose(() => {
        console.log('disposeHandlers');
        if(!global['${GLOBAL_DISPOSE_STYLE_NAME}']) {
          global['${GLOBAL_DISPOSE_STYLE_NAME}'] = [];
        }
        global['${GLOBAL_DISPOSE_STYLE_NAME}'] = global['${GLOBAL_DISPOSE_STYLE_NAME}'].concat('${contentHash}');
      })
    }
  })()`;
  return `module.exports=${code}`;
}
function hippyVueCSSLoader ( source ) { const options = getOptions ( this ) ; const parsed = parseCSS ( source , { source : sourceId } ) ; const majorNodeVersion = parseInt ( process . versions . node . split ( '.' ) [ 0 ] , 10 ) ; const hashType = majorNodeVersion >= 17 ? 'md5' : 'md4' ; const hash = crypto . createHash ( hashType ) ; const contentHash = hash . update ( source ) . digest ( 'hex' ) ; sourceId += 1 ; const rulesAst = parsed . stylesheet . rules . filter ( n => n . type === 'rule' ) . map ( n => ( { hash : contentHash , selectors : n . selectors , declarations : n . declarations . map ( ( dec ) => { let { value } = dec ; if ( dec . property && dec . property . toLowerCase ( ) . indexOf ( 'color' ) > - 1 ) { value = translateColor ( value , options ) ; } return { type : dec . type , property : dec . property , value , } ; } ) , } ) ) ; const code = ` ${ GLOBAL_STYLE_NAME } ${ GLOBAL_STYLE_NAME } ${ GLOBAL_STYLE_NAME } ${ GLOBAL_STYLE_NAME } ${ JSON . stringify ( rulesAst ) } ${ GLOBAL_DISPOSE_STYLE_NAME } ${ GLOBAL_DISPOSE_STYLE_NAME } ${ GLOBAL_DISPOSE_STYLE_NAME } ${ GLOBAL_DISPOSE_STYLE_NAME } ${ contentHash } ` ; return ` ${ code } ` ; }
Convert the CSS text to AST that able to parse by selector parser.
Convert the CSS text to AST that able to parse by selector parser .
// FIXME: Should have a strict property with colors map.