- create a project with vanilla
yarn create vite vite-for-ie11 --template vanilla
- install plugin
@vitejs/plugin-legacy
yarn add @vitejs/plugin-legacy -D
- create config file and set configs
I just follow the tutorial
touch vite.config.js
// vite.config.js
import legacy from "@vitejs/plugin-legacy";
export default {
plugins: [
legacy({
// for ie11
targets: ["ie >= 11"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
}),
],
};
- add the test code
read the
./index.html
for detail.
const apis = ["Proxy", "Reflect", "Promise", "Set", "Map"];
document.querySelector("#app").innerHTML = `
<h1>Hello Vite!</h1>
<a href="https://vitejs.dev/guide/features.html" target="_blank">Documentation</a>
<ol>${apis
.map((v) => `<li>${v}: ${Boolean(window[v]) ? "yes" : "no"}</li>`)
.join("")}</ol>
`;
Then I run yarn serve
, I got a error msg: Unhandled promise rejection TypeError: Target is not iterable