Va1/string-replace-loader

Does not replace text while app running with hot-reload.

Closed this issue · 1 comments

Issue: Does not replace text while app running with hot-reload.

Config

{
  loader: 'string-replace-loader',
    options: {
      search: '__SMALL_VIEW_MEDIA_QUERY__',
      replace: `max-width: ${webpackCompileTimeVars.smallViewMaxWidth}px`
    }
}

Compile Time Replacement Works Great

Screenshot 2024-03-22 at 6 44 50 AM

Hot-Update Payload is not Transformed by Plugin

Screenshot 2024-03-22 at 6 47 28 AM

System Info

  System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.20 GB / 32.00 GB
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    Yarn: 1.22.18 - /opt/homebrew/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
  Browsers:
    Edge: 122.0.2365.92
    Safari: 17.3.1
  Packages:
    babel-loader: 9.1.3 => 9.1.3 
    copy-webpack-plugin: 12.0.2 => 12.0.2 
    css-loader: 6.8.1 => 6.8.1 
    html-webpack-plugin: 5.5.4 => 5.5.4 
    string-replace-loader: 3.1.0 => 3.1.0 
    webpack: 5.90.3 => 5.90.3 
    webpack-cli: 5.1.4 => 5.1.4 
    webpack-hot-middleware: 2.26.1 => 2.26.1 
    webpack-manifest-plugin: 5.0.0 => 5.0.0 
  Global Packages:
    webpack: 5.90.3

How can I enable this transformation for hot-reload?

Sorry, yes it does. The root cause of my issue was needing to specify global regex like so:

search: /<search-phrase>/g