string-replace-webpack-plugin

WebJar for string-replace-webpack-plugin

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

string-replace-webpack-plugin
Last Version

Last Version

0.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

string-replace-webpack-plugin
WebJar for string-replace-webpack-plugin
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/jamesandersen/string-replace-webpack-plugin

Download string-replace-webpack-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/string-replace-webpack-plugin/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>string-replace-webpack-plugin</artifactId>
    <version>0.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/string-replace-webpack-plugin/
implementation 'org.webjars.npm:string-replace-webpack-plugin:0.1.3'
// https://jarcasting.com/artifacts/org.webjars.npm/string-replace-webpack-plugin/
implementation ("org.webjars.npm:string-replace-webpack-plugin:0.1.3")
'org.webjars.npm:string-replace-webpack-plugin:jar:0.1.3'
<dependency org="org.webjars.npm" name="string-replace-webpack-plugin" rev="0.1.3">
  <artifact name="string-replace-webpack-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='string-replace-webpack-plugin', version='0.1.3')
)
libraryDependencies += "org.webjars.npm" % "string-replace-webpack-plugin" % "0.1.3"
[org.webjars.npm/string-replace-webpack-plugin "0.1.3"]

Dependencies

compile (5)

Group / Artifact Type Version
org.webjars.npm : loader-utils jar [0.2.3,0.3)
org.webjars.npm : async jar [0.2.10,0.3)
org.webjars.npm : css-loader Optional jar [0.9.1,0.10)
org.webjars.npm : file-loader Optional jar [0.8.1,0.9)
org.webjars.npm : style-loader Optional jar [0.8.3,0.9)

Project Modules

There are no modules declared in this project.

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.replace([nextLoaders: string], options, [prevLoaders: string])
  • nextLoaders loaders to follow the replacement
  • options
    • replacements disables the plugin
  • prevLoaders loaders to apply prior to the replacement

License

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

Versions

Version
0.1.3