html-webpack-injector
Advanced tools
Comparing version 1.1.2 to 1.1.3
16
index.js
@@ -32,5 +32,5 @@ const HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
if (typeof asyncNames === "object" && typeof deferNames === "object") { | ||
if(typeof asyncNames === "object" && asyncNames?.length){ | ||
tags.forEach(tag => { | ||
// add async/defer only on script tags. | ||
// add async only on script tags. | ||
if (!tag.attributes.href && tag.attributes.src) { | ||
@@ -40,2 +40,10 @@ asyncNames.forEach(name => { | ||
}); | ||
} | ||
}); | ||
} | ||
if(typeof deferNames === "object" && deferNames?.length){ | ||
tags.forEach(tag => { | ||
// add defer only on script tags. | ||
if (!tag.attributes.href && tag.attributes.src) { | ||
deferNames.forEach(name => { | ||
@@ -46,6 +54,2 @@ addAttributesToTag(tag, name, {defer: true}); | ||
}); | ||
} else { | ||
console.log("-------------------------------------"); | ||
console.error("Invalid value given to chunksConfig option"); | ||
console.log("-------------------------------------"); | ||
} | ||
@@ -52,0 +56,0 @@ } |
{ | ||
"name": "html-webpack-injector", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Helps to inject chunks to head and body via HtmlWebpackPlugin with additional options to add async/defer to chunks", | ||
@@ -17,5 +17,5 @@ "main": "index.js", | ||
], | ||
"repository": "https://github.com/thearchitgarg/html-webpack-injector.git", | ||
"author": "Archit garg <thearchitgargg@gmail.com> (https://github.com/thearchitgarg)", | ||
"repository": "https://github.com/architgarg/html-webpack-injector.git", | ||
"author": "Archit garg <thearchitgargg@gmail.com> (https://github.com/architgarg)", | ||
"license": "ISC" | ||
} |
@@ -1,7 +0,7 @@ | ||
<div align="center"> | ||
<h1>HTML Webpack Injector Plugin</h1> | ||
<p>Plugin that simplifies injection of chunks into <b>head</b> and <b>body</b> using <a href="https://github.com/jantimon/html-webpack-plugin">HtmlWebpackPlugin</a></p> | ||
<div> | ||
<h1 align="center">HTML Webpack Injector Plugin</h1> | ||
<p>Plugin that simplifies injection of chunks into <b>head</b> and <b>body</b> using <a href="https://github.com/jantimon/html-webpack-plugin">HtmlWebpackPlugin</a> (with ability to provide async/defer)</p> | ||
</div> | ||
<h2 align="center">Installation</h2> | ||
<h2>Installation</h2> | ||
@@ -20,3 +20,3 @@ ```bash | ||
<h2 align="center">Usage</h2> | ||
<h2>Usage</h2> | ||
Suppose you want have `2 chunks` that you want to inject in the html document using HtmlWebpackPlugin. If you want to inject `one chunk in head` and `one chunk in body` of the same html document. | ||
@@ -44,3 +44,3 @@ | ||
}), | ||
new HtmlWebpackInjector() | ||
new HtmlWebpackInjector() // Initialize plugin | ||
] | ||
@@ -69,3 +69,3 @@ } | ||
<h2 align="center">Provide Async Defer (Optional)</h2> | ||
<h2>Provide Async Defer (Optional)</h2> | ||
You can specify scripts to be async or defer by adding additional `chunksConfig` option. | ||
@@ -84,4 +84,4 @@ | ||
}), | ||
new HtmlWebpackInjector() | ||
new HtmlWebpackInjector() | ||
] | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
78
5783
3
1