webpack-replace-string-loader

1.0.2 • Public • Published

A simple webpack loader to replace all occurences of strings inside your files

Usage :

webpack.config.js

module.exports = {
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
            {
            loader: 'webpack-replace-string-loader',
            options: {
              matchingArray: [
                { match: 'Hello', replace: 'Bonjour' },
                { match: 'Earth', replace: 'Moon' }
              ]
            },
          },
        ],
      },
    ],
  },
};

Will transform

const myText = 'Hello, this is a test'
const answer = 'Hello test, this is the Earth'

to

const myText = 'Bonjour, this is a test'
const answer = 'Bonjour test, this is the Moon'

/webpack-replace-string-loader/

    Package Sidebar

    Install

    npm i webpack-replace-string-loader

    Weekly Downloads

    3

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    8.13 kB

    Total Files

    11

    Last publish

    Collaborators

    • thibautsabot