UNPKG
pre-fetch-plugin
Version:
latest (1.0.0)
1.0.0
A pre-fetch plugin for Vite and Webpack
pre-fetch-plugin
/
dist
/
plugins
/
vite-plugin.js
13 lines
(12 loc)
•
373 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
import
{ injectScriptToHtml }
from
'../core/utils'
;
export
function
createVitePlugin
(
pluginOptions
) {
return
{
name
:
'pre-fetch-plugin'
,
transformIndexHtml
: {
enforce
:
'pre'
,
transform
:
async
(html) => {
return
await
injectScriptToHtml
(html, pluginOptions.
options
); }, }, }; }