Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

string-replace-loader

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-replace-loader

Replace loader for Webpack

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
256K
decreased by-5.97%
Maintainers
1
Weekly downloads
 
Created

What is string-replace-loader?

string-replace-loader is a webpack loader that allows you to replace strings in your files during the build process. This can be useful for tasks such as replacing environment variables, removing debug code, or making other text substitutions in your source files.

What are string-replace-loader's main functionalities?

Basic String Replacement

This feature allows you to replace a specific string with another string in your JavaScript files. In this example, every occurrence of 'foo' in the .js files will be replaced with 'bar'.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'string-replace-loader',
        options: {
          search: 'foo',
          replace: 'bar',
        },
      },
    ],
  },
};

Regular Expression Replacement

This feature allows you to use regular expressions for more complex string replacements. In this example, any string matching the pattern 'foo' followed by one or more digits will be replaced with 'bar'.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'string-replace-loader',
        options: {
          search: /foo\d+/g,
          replace: 'bar',
        },
      },
    ],
  },
};

Multiple Replacements

This feature allows you to perform multiple string replacements in a single pass. In this example, 'foo' will be replaced with 'bar' and 'baz' will be replaced with 'qux' in the .js files.

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'string-replace-loader',
        options: {
          multiple: [
            { search: 'foo', replace: 'bar' },
            { search: 'baz', replace: 'qux' }
          ],
        },
      },
    ],
  },
};

Other packages similar to string-replace-loader

Keywords

FAQs

Package last updated on 26 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc