html-inline-webpack-plugin
Advanced tools
Comparing version 1.0.0-beta5 to 1.0.0-beta6
@@ -20,5 +20,3 @@ (function (factory) { | ||
createBlobSource(context) { | ||
return context.assetSource | ||
.replaceAll("`", "\\`") | ||
.replaceAll("$", "\\$"); | ||
return context.assetSource.replaceAll("`", "\\`"); | ||
} | ||
@@ -25,0 +23,0 @@ perform(context, parent) { |
@@ -32,3 +32,3 @@ (function (factory) { | ||
if (this.isInline) { | ||
target.textContent = context.assetSource; | ||
target.textContent = this.createSource(context); | ||
// A given asset has already been inserted into the document, | ||
@@ -52,2 +52,10 @@ // so there is no need to output it separately. | ||
} | ||
createSource(context) { | ||
if (this.options.scriptLoading == "DEFAULT") { | ||
return context.assetSource; | ||
} | ||
else { // is "DEFER" and "ASYNC" | ||
return `addEventListener("DOMContentLoaded", () => {${context.assetSource}});`; | ||
} | ||
} | ||
createElement() { | ||
@@ -72,2 +80,5 @@ return new node_html_parser_1.HTMLElement("script", {}); | ||
class StyleAssetInjector extends DrivenAssetInjector { | ||
createSource(context) { | ||
return context.assetSource; | ||
} | ||
createElement() { | ||
@@ -74,0 +85,0 @@ return new node_html_parser_1.HTMLElement(this.isInline ? "style" : "link", {}); |
@@ -30,4 +30,5 @@ import { HTMLElement } from "node-html-parser"; | ||
get isInline(): boolean; | ||
abstract createSource(context: AssetInjectorContext): string; | ||
abstract setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
perform(context: AssetInjectorContext, parent: HTMLElement): void; | ||
abstract setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
} | ||
@@ -44,2 +45,3 @@ /** This class performs injecting HTML element about javascript assets. */ | ||
}); | ||
createSource(context: AssetInjectorContext): string; | ||
createElement(): HTMLElement; | ||
@@ -50,4 +52,5 @@ setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
export declare class StyleAssetInjector extends DrivenAssetInjector { | ||
createSource(context: AssetInjectorContext): string; | ||
createElement(): HTMLElement; | ||
setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
} |
{ | ||
"name": "html-inline-webpack-plugin", | ||
"description": "This webpack plugin package is bundling related HTML files by injecting inline tags.", | ||
"version": "1.0.0-beta5", | ||
"version": "1.0.0-beta6", | ||
"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-beta5</th> | ||
<th>v1.0.0-beta6</th> | ||
</tr> | ||
@@ -11,0 +11,0 @@ </tbody> |
@@ -11,5 +11,3 @@ import { HTMLElement } from "node-html-parser"; | ||
createBlobSource(context: AssetInjectorContext<string>): string { | ||
return context.assetSource | ||
.replaceAll("`", "\\`") | ||
.replaceAll("$", "\\$"); | ||
return context.assetSource.replaceAll("`", "\\`"); | ||
} | ||
@@ -16,0 +14,0 @@ |
@@ -34,2 +34,5 @@ import { HTMLElement } from "node-html-parser"; | ||
abstract createSource(context: AssetInjectorContext): string; | ||
abstract setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
perform(context: AssetInjectorContext, parent: HTMLElement): void { | ||
@@ -39,3 +42,3 @@ const target = this.createElement(context); | ||
if (this.isInline) { | ||
target.textContent = context.assetSource; | ||
target.textContent = this.createSource(context); | ||
@@ -51,4 +54,2 @@ // A given asset has already been inserted into the document, | ||
} | ||
abstract setAttribute(context: AssetInjectorContext, element: HTMLElement): void; | ||
} | ||
@@ -62,2 +63,10 @@ | ||
createSource(context: AssetInjectorContext): string { | ||
if (this.options.scriptLoading == "DEFAULT") { | ||
return context.assetSource; | ||
} else { // is "DEFER" and "ASYNC" | ||
return `addEventListener("DOMContentLoaded", () => {${context.assetSource}});`; | ||
} | ||
} | ||
createElement(): HTMLElement { | ||
@@ -80,2 +89,6 @@ return new HTMLElement("script", {}); | ||
export class StyleAssetInjector extends DrivenAssetInjector { | ||
createSource(context: AssetInjectorContext): string { | ||
return context.assetSource; | ||
} | ||
createElement(): HTMLElement { | ||
@@ -82,0 +95,0 @@ return new HTMLElement(this.isInline ? "style" : "link", {}); |
44734
847