From 8b2e78522c2df18da0de9de811cad2f63f1c43b5 Mon Sep 17 00:00:00 2001 From: Petr Tsymbarovich Date: Tue, 21 Jan 2020 01:20:06 +0300 Subject: [PATCH] Refactoring --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index aa60d71..7c83e89 100644 --- a/src/index.ts +++ b/src/index.ts @@ -176,7 +176,7 @@ export default ({ preload, modules, minify: minifyOptions, - onlinePath: onlinePath, + onlinePath = '', ...options }: IPluginOptions): Plugin => ({ name: 'html2', @@ -331,12 +331,12 @@ consider to use the esm format or switch off the option`) const {name, ext} = path.parse(fileName) const injectType = ext.slice(1) if (name in entries) { - injectCSSandJS((onlinePath === undefined ? '' : onlinePath) + '/' + fileName, injectType, inject) + injectCSSandJS(`${onlinePath}/${fileName}`, injectType, inject) } else if (name in dynamicEntries && (preload as Set).has(dynamicEntries[name])) { const linkType = extensionToType(injectType) if (linkType) { addNewLine(head) - head.appendChild(new HTMLElement('link', {}, `rel="preload" href="${(onlinePath === undefined ? '' : onlinePath)}/${fileName}" as="${linkType}"`)) + head.appendChild(new HTMLElement('link', {}, `rel="preload" href="${onlinePath}/${fileName}" as="${linkType}"`)) } } })