Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
icai opened this issue Apr 9, 2021 · 2 comments

Comments

@icai
Copy link

icai commented Apr 9, 2021

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;
          },
        }
      }
    ]
  }
}

const newSource = source.replace(search, replace)

@Va1
Copy link
Owner

Va1 commented Apr 13, 2021

hi!

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

@icai
Copy link
Author

icai commented Apr 13, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants