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

string-replace-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-replace-webpack-plugin

Replace string tokens in the contents of a file.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-5.63%
Maintainers
1
Weekly downloads
 
Created
Source

string replace plugin for webpack

Usage example

var StringReplacePlugin = require("string-replace-webpack-plugin");
module.exports = {
	module: {
		loaders: [
		    // configure replacements for file patterns
			{ test: /index.html$/,    loader: StringReplacePlugin.replace({
                replacements: [
                    {
                        pattern: /<!-- @secret (\w*?) -->/ig,
                        replacement: function (match, p1, offset, string) {
                            return secrets.web[p1];
                        }
                    }
                ]})
            }
		]
	},
	plugins: [
	    // an instance of the plugin must be present
		new StringReplacePlugin()
	]
}

This allows for arbitrary strings to be replaced as part of the module build process. The original intent is to replace API keys in modules prior to deployment.

API

StringReplacePlugin([nextLoaders: string], options, [prevLoaders: string])
  • nextLoaders loaders to follow the replacement
  • options
    • replacements disables the plugin
      • pattern a regex to match against the file contents
      • replacement an ECMAScript string replacement function
  • prevLoaders loaders to apply prior to the replacement

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Keywords

FAQs

Package last updated on 30 Jun 2015

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