string-replace-loader icon indicating copy to clipboard operation
string-replace-loader copied to clipboard

support callback function in options, make sure user can custom personal search rule.

Open icai opened this issue 4 years ago • 2 comments


module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /image\/*$/,
        loader: 'string-replace-loader',
        options: {
          // search: '$', disable search
          replace:(content)=> {
              maps.forEach(item => {
                  content = content.replace(item, `${cdn}${item}`)
              })
              return content;
          },
        }
      }
    ]
  }
}



https://github.com/Va1/string-replace-loader/blob/54238608c65d6ce59d58371f4a7881c9d2807605/lib/replace.js#L18

icai avatar Apr 09 '21 10:04 icai

hi!

this is already implemented, please refer to documentation – https://github.com/Va1/string-replace-loader#callback-replacement

Va1 avatar Apr 13 '21 09:04 Va1

@Va1 different with the document,no need to search option, just a callback function for user, get more possibility.

icai avatar Apr 13 '21 17:04 icai