-
Notifications
You must be signed in to change notification settings - Fork 154
/
animateSupport.js
15 lines (14 loc) · 768 Bytes
/
animateSupport.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from "url";
const curFilename = fileURLToPath(import.meta.url);
const curDirname = path.dirname(curFilename);
const indexFile = path.join(curDirname, "dist/index.html");
fs.readFile(indexFile, "utf-8").then((data) => {
//在第一个<script前添加document.getAnimations=[]
data = data.replace(
/<script /,
`<script>var script = document.createElement('script');script.src = 'https://cdnjs.cloudflare.com/ajax/libs/web-animations/2.3.2/web-animations-next.min.js';script.onload=function(){document.getAnimations=window.Element.prototype.getAnimations;};document.head.appendChild(script);</script><script></script><script `
);
fs.writeFile(indexFile, data, "utf-8");
});