Va1 / string-replace-loader

Replace loader for Webpack
MIT License
250 stars 57 forks source link

How can I get current filename from rule.test in replace function? #66

Closed Zummer closed 2 years ago

Zummer commented 3 years ago
{
   test: /\.js$/,
   loader: 'string-replace-loader',
  options: {
      search: /__\w{6}\b/g,
      replace: function () {
          return `${current filename? or pathname?}`; // this.resourcePath ?
      },
  },
Zummer commented 3 years ago

where is this commit? I did not find it in project https://github.com/Va1/string-replace-loader/pull/55/commits/69f4c497ea03b9c4a84ff2f18513a6943931434a

Va1 commented 2 years ago

@smartin85 's PR merged and released as v3.1.0. Replace function now has the context of the loader which allows for getting the filename beyond other things.