diff --git a/README.md b/README.md index 21dfac1..0d8d91e 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ This is a fork of [preload-webpack-plugin](https://github.com/GoogleChromeLabs/p - Added an `includeHtmlNames` option so that the plugin is only applied to a specific HTML file. +- If you want to specify the inject position of preload/prefetch tags in your html, add `` html comment tags in your [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) template file, and it will be replaced by preload/prefetch resources tags. + - Drops support for Node < 6. --- diff --git a/src/lib/insert-links-into-head.js b/src/lib/insert-links-into-head.js index 9db83fa..ea108a8 100644 --- a/src/lib/insert-links-into-head.js +++ b/src/lib/insert-links-into-head.js @@ -20,6 +20,11 @@ function insertLinksIntoHead({html, links=[]}) { return html; } + if (html.match(//)) { + //If there's a to specify inject position, replace it with links + return html.replace(//, links.join('')); + } + if (html.includes('')) { // If a valid closing is found, insert the new s right before it. return html.replace('', links.join('') + '');