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

html-replace-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-replace-webpack-plugin - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

10

index.js

@@ -6,3 +6,3 @@ function HtmlReplaceWebpackPlugin(options)

{
regex: undefined,
pattern: undefined,
replacement: undefined

@@ -13,6 +13,6 @@ }]

{
if(typeof option.regex == 'undefined' ||
if(typeof option.pattern == 'undefined' ||
typeof option.replacement == 'undefined')
{
throw new Error('Both regex and replacement options must be defined!')
throw new Error('Both `pattern` and `replacement` options must be defined!')
}

@@ -28,3 +28,3 @@ })

var matches = null
while((matches = option.regex.exec(htmlData)) != null)
while((matches = option.pattern.exec(htmlData)) != null)
{

@@ -39,3 +39,3 @@ var replacement = option.replacement.apply(null, matches)

{
htmlData = htmlData.replace(option.regex, option.replacement)
htmlData = htmlData.replace(option.pattern, option.replacement)
}

@@ -42,0 +42,0 @@ })

{
"name": "html-replace-webpack-plugin",
"version": "2.2.0",
"description": "A Webpack plugin for replace HTML contents with custom pattern(string or regex)",
"version": "2.2.1",
"description": "A Webpack plugin for replace HTML contents with custom pattern string or regex.",
"main": "index.js",

@@ -20,3 +20,3 @@ "scripts": {

],
"author": "Nathanie",
"author": "aeiou <iminif@outlook.com>",
"license": "MIT",

@@ -23,0 +23,0 @@ "bugs": {

@@ -1,3 +0,3 @@

# html-replace-webpack-plugin [npm-url]
A Webpack plugin for replace HTML contents with custom pattern(string or regex).
# [html-replace-webpack-plugin]
A Webpack plugin for replace HTML contents with custom pattern string or regex.

@@ -9,3 +9,3 @@ ## Usage

```shell
npm install --save-dev html-replace-webpack-plugin
npm install html-replace-webpack-plugin --save-dev
```

@@ -21,4 +21,2 @@

module.exports = {
// Definition for entry, output, module...
// Definition for Webpack plugins

@@ -29,12 +27,11 @@ plugin: [

{
regex: 'foo',
pattern: 'foo',
replacement: '`foo` has been replaced with `bar`'
},
,
}, ,
{
regex: '@@title',
pattern: '@@title',
replacement: 'html replace webpack plugin'
},
{
regex: /(<!--\s*|@@)(css|js|img):([\w-\/]+)(\s*-->)?/g,
pattern: /(<!--\s*|@@)(css|js|img):([\w-\/]+)(\s*-->)?/g,
replacement: function(match, $1, type, file, $4, index, input)

@@ -46,3 +43,2 @@ {

// file: bootstrap
//
// Then fetch css link from some resource object

@@ -65,3 +61,2 @@ // var url = resources['css']['bootstrap']

'bootstrap': '//cdn/bootstrap/bootstrap.min.js'
// ...
},

@@ -71,3 +66,2 @@ css:

'bootstrap': '//cdn/bootstrap/bootstrap.min.css'
// ...
},

@@ -77,3 +71,2 @@ img:

'the-girl': '//cdn/img/the-girl.jpg'
// ...
}

@@ -134,3 +127,3 @@ }

### objN.regex
#### objN.pattern
Type: `String` | `RegExp`

@@ -140,3 +133,3 @@

### objN.replacement
#### objN.replacement
Type: `String` | `Function`

@@ -146,4 +139,4 @@

[npm-url]: https://www.npmjs.com/package/html-replace-webpack-plugin
[html-replace-webpack-plugin]: https://www.npmjs.com/package/html-replace-webpack-plugin
[MDN documentation for RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
[MDN documentation for String.replace]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
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