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

html-beautify-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.0.4 to 1.0.5

39

index.js

@@ -0,1 +1,2 @@

const webpack = require('webpack')
const _ = require('lodash')

@@ -5,2 +6,3 @@ const chalk = require('chalk')

const beautify = require('js-beautify').html
const webpackLatest = !_.isNil(webpack.version) && /.*4(\.\d+){0,2}/gi.test(webpack.version)

@@ -25,16 +27,29 @@ function HtmlBeautifyPlugin ({ config = {}, replace } = { config: {}, replace: [] }) {

function htmlPluginDataFunction (htmlPluginData, callback, _this) {
htmlPluginData.html = beautify(_.reduce(_this.options.replace, (res, item) => {
if(typeof item === 'string' || item instanceof RegExp)
return res.replace(item instanceof RegExp ? item : new RegExp(item, 'gi'), '')
else
return res.replace(item.test instanceof RegExp ? item.test : new RegExp(item.test, 'gi'), item.with || '')
}, htmlPluginData.html), _this.options.config)
callback(null, htmlPluginData)
}
HtmlBeautifyPlugin.prototype.apply = function (compiler) {
compiler.plugin('compilation', compilation =>
compilation.plugin('html-webpack-plugin-after-html-processing', (htmlPluginData, callback) => {
htmlPluginData.html = beautify(_.reduce(this.options.replace, (res, item) => {
if(typeof item === 'string' || item instanceof RegExp)
return res.replace(item instanceof RegExp ? item : new RegExp(item, 'gi'), '')
else
return res.replace(item.test instanceof RegExp ? item.test : new RegExp(item.test, 'gi'), item.with || '')
}, htmlPluginData.html), this.options.config)
callback(null, htmlPluginData)
}))
if (!webpackLatest) {
compiler.plugin('compilation', compilation =>
compilation.plugin('html-webpack-plugin-after-html-processing', (htmlPluginData, callback) => {
htmlPluginDataFunction(htmlPluginData, callback, this)
})
)
} else {
compiler.hooks.compilation.tap('HtmlBeautifyPlugin', compilation =>
compilation.hooks.htmlWebpackPluginAfterHtmlProcessing.tapAsync('HtmlBeautifyPlugin', (htmlPluginData, callback) => {
htmlPluginDataFunction(htmlPluginData, callback, this)
})
)
}
}
module.exports = HtmlBeautifyPlugin
module.exports = HtmlBeautifyPlugin
{
"name": "html-beautify-webpack-plugin",
"version": "1.0.4",
"version": "1.0.5",
"description": "Adapter for beautifyjs as webpack plugin, chained with HtmlWebpackPlugin",

@@ -5,0 +5,0 @@ "main": "index.js",

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