You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GCSGUI/update-index.mjs

16 lines
543 B
JavaScript

import fs from 'fs';
console.time('转换用时');
const distPath = './dist/index.html'; //打包路径的index.html
let htmlText = fs.readFileSync(distPath, 'utf8');
let resultText = '';
let htmlArr = htmlText.match(/.*\n/g) || [];
htmlArr.forEach(str => {
str = str.replace(/\s?nomodule\s?/g,' ');
str = str.replace(/\s?crossorigin\s?/g,' ');
str = str.replace(/data-src/g,'src');
if(!/type="module"/i.test(str))
resultText += str;
});
fs.writeFileSync(distPath,resultText,'utf8');
console.timeEnd('转换用时');