You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

html-inline-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version

to
1.0.0-alpha5

dist/index.js

2

package.json
{
"name": "html-inline-webpack-plugin",
"description": "This webpack plugin package is bundling related HTML files by injecting inline tags.",
"version": "1.0.0-alpha2",
"version": "1.0.0-alpha5",
"main": "./dist/index.js",

@@ -6,0 +6,0 @@ "types": "./dist/types/index.d.ts",

@@ -8,3 +8,3 @@ <div align="center">

<th>Version</th>
<th>v1.0.0-alpha2</th>
<th>v1.0.0-alpha5</th>
</tr>

@@ -11,0 +11,0 @@ </tbody>

import { AssetInjector } from "./asset_injector";
export abstract class AssetInsertorWithBlob<T> extends AssetInjector<T> {
// TODO: ...
blobOf() {
}
}
import { HTMLElement } from "node-html-parser";
import { Compilation } from "webpack";
/**
* Signature for the interface that defines the required information
* for injecting HTML elements about asset.
*
* Used by [AssetInjector].
*/
export interface AssetInjectorContext {

@@ -9,2 +15,3 @@ compilation: Compilation;

/** This class provides injecting HTML elements about asset. */
export abstract class AssetInjector<T> {

@@ -15,11 +22,9 @@ abstract createElement(): HTMLElement;

export interface DrivenAssetInjectorOptions {
inline: boolean;
}
/** This class provides injecting HTML elements about asset based on the string. */
export abstract class DrivenAssetInjector extends AssetInjector<string> {
constructor(public options: DrivenAssetInjectorOptions) {
constructor(public options: {inline: boolean}) {
super();
}
/** Whether to include asset data within the tag for synchronous data loading. */
get isInline(): boolean {

@@ -36,3 +41,3 @@ return this.options.inline;

} else {
target.setAttribute("src", context.assetName);
this.setAttribute(context, target);
}

@@ -42,2 +47,4 @@

}
abstract setAttribute(context: AssetInjectorContext, element: HTMLElement): void;
}

@@ -49,2 +56,7 @@

}
setAttribute(context: AssetInjectorContext, element: HTMLElement): void {
element.setAttribute("defer", "");
element.setAttribute("src", context.assetName);
}
}

@@ -54,4 +66,9 @@

createElement(): HTMLElement {
return new HTMLElement("style", {});
return new HTMLElement(this.isInline ? "style" : "link", {});
}
setAttribute(context: AssetInjectorContext, element: HTMLElement): void {
element.setAttribute("href", context.assetName);
element.setAttribute("rel", "stylesheet");
}
}

@@ -15,3 +15,3 @@ import { Compilation, Compiler, sources } from "webpack";

inject?: boolean;
injectByBlob: boolean;
// injectByBlob: boolean;
inline?: boolean;

@@ -40,3 +40,3 @@ pretty?: boolean;

const inject = this.options?.inject ?? true;
const injectByBlob = this.options?.injectByBlob ?? true;
// const injectByBlob = this.options?.injectByBlob ?? true;
const inline = this.options?.inline ?? mode == "production";

@@ -50,3 +50,3 @@ const pretty = this.options?.pretty ?? false;

inject: inject,
injectByBlob: injectByBlob,
// injectByBlob: injectByBlob,
inline: inline,

@@ -98,2 +98,6 @@ pretty: pretty,

for (const asset in compilation.assets) {
if (asset.endsWith("hot-update.js")) {
continue;
}
const source = compilation.assets[asset].source() as string;

@@ -100,0 +104,0 @@ const active = this.injectors.get(path.extname(asset));

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.