跳到主要内容

vite:html-inline-script-proxy

2023年12月28日
柏拉文
越努力,越幸运

一、认识


对于 HTML 中的内联脚本,Vite 会通过 vite:html-inline-script-proxy 插件来进行加载。比如下面这个 script 标签:

<script type="module">
import React from 'react';
console.log(React)
</script>

这些内容会在后续的 build-html 插件从 HTML 代码中剔除,并且变成下面的这一行代码插入到项目入口模块的代码中:

import '/User/xxx/vite-app/index.html?http-proxy&index=0.js'

vite:html-inline-script-proxy 就是用来加载这样的模块