From c911cf2ce7c9745d0ff4eb35f3291a8df175eac3 Mon Sep 17 00:00:00 2001
From: Rory Casey
Date: Thu, 20 Sep 2018 14:07:21 +1200
Subject: [PATCH] Update index.ts
---
src/index.ts | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/index.ts b/src/index.ts
index 49d532b..8a21b67 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -18,16 +18,12 @@ interface Config {
}
export default class Plugin
-{
- static addStyle(html: string, style: string) {
- return html.replace('', ``);
- }
-
- static removeLinkTag(html: string, cssFileName: string) {
+{
+ static replaceLinkWithStyle(html: string, style: string, cssFileName: string) {
return html.replace(
new RegExp(`]+href=['"]${cssFileName}['"][^>]+(>|\/>|><\/link>)`),
- '',
- );
+ ``
+ );
}
private config: Config;
@@ -71,8 +67,7 @@ export default class Plugin
let html = this.html[htmlFileName];
Object.keys(this.css).forEach((key) => {
- html = Plugin.addStyle(html, this.css[key]);
- html = Plugin.removeLinkTag(html, publicPath + key);
+ html = Plugin.replaceLinkWithStyle(html, this.css[key], publicPath + key);
});
assets[htmlFileName] = {
@@ -94,4 +89,4 @@ export default class Plugin
function is(filenameExtension: string) {
const reg = new RegExp(`\.${filenameExtension}$`);
return (fileName: string) => reg.test(fileName);
-}
\ No newline at end of file
+}