Va1/string-replace-loader

How can I get a file name in the replace fn?

michaltaberski opened this issue · 1 comments

I is it possible to retrieve information about the file context where the replace is happening? Just like this:

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'string-replace-loader',
        options: {
          search: '%%FILE_PATH%%',
          replace(match, p1, offset, string) {
            // Is there a way to get FULL_FILE_PATH like `/src/components/button.js?
            // the file that match rule's test 
            return FULL_FILE_PATH;
          },
          flags: 'g'
        }
      }
    ]
  }
}
Va1 commented

duplicate: #66

this feature was implemented and released as v3.1.0. check the docs. thank you.