Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mentaljam committed Jan 20, 2020
1 parent e043e6a commit 8b2e785
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default ({
preload,
modules,
minify: minifyOptions,
onlinePath: onlinePath,
onlinePath = '',
...options
}: IPluginOptions): Plugin => ({
name: 'html2',
Expand Down Expand Up @@ -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<string>).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}"`))
}
}
})
Expand Down

0 comments on commit 8b2e785

Please sign in to comment.