cuth / postcss-pxtorem

Convert pixel units to rem (root em) units using PostCSS
MIT License
2.02k stars 174 forks source link

Some errors happen when set exclude value to function: Range out of order in character class In regex. #93

Open ChrisMiaoMiao opened 1 year ago

ChrisMiaoMiao commented 1 year ago

I am using version "postcss-pxtorem": "^6.0.0" and I'm having the same issue. This is part of my config in postcss.config.js.

  'postcss-pxtorem': {
      rootValue: 37.5,
      propList: ['*'],
      unitPrecision: 5,
      exclude: (file) => {
        const BLACK_LIST = [
          // cause error
          'pages/patient-report/fang' 
        ]
        return BLACK_LIST.some(item => file.indexOf(item) !== -1)
      }
    }

When I execute the plugin, I will get the following errors,I think the error occurs when call the function filePath.match(exclude).

CleanShot 2023-01-13 at 17 46 52

Tommy0121 commented 7 months ago

Still not fixed? I use this way to avoid this error

  'postcss-pxtorem': {
      rootValue: 37.5,
      propList: ['*'],
      unitPrecision: 5,
      exclude: (file) => {
        return file.indexOf('index.html') !== -1 ||   file.indexOf('live') !== -1 
      }
    }