Va1 / string-replace-loader

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

Webpack 4 - Replace values inside json file #68

Open Stebeber opened 3 years ago

Stebeber commented 3 years ago

Hello everyone,

I am using Webpack 4.46.0 with "string-replace-loader" 2.3.0.

I am not able to replace any strings in my *.json files. I have various "app.json" files in different folders - therefore I want to replace some values inside.

Config:

 module: {
    rules: [
      {
        test: /app\.json$/,
        loader: 'string-replace-loader',
        options: {
          multiple: [
            { search: './data_a', replace: '../../data_a', flags: 'g'},
            { search: './data_b', replace: '../../data_b', flags: 'g' },
          ],
        },
      },

Any ideas what I am doing wrong?

Stebeber commented 3 years ago
rules: [
      {
        test: /\.json$/,
        loader: 'string-replace-loader',
        options: {
          search: './data',
          replace: '../../data',
          flags: 'g',
          strict: true,
        },
      },

Using strict mode fails - so it seems to me that the files are not found. Any ideas?