| 8 | const EXPORT_HTML = process.env.EXPORT_HTML |
| 9 | |
| 10 | const generateHTML = (config, info = '') => { |
| 11 | const content = fs.readFileSync(config[1], { encoding: 'utf8' }) |
| 12 | let html = |
| 13 | content.match(/<!DOCTYPE html>([\s\S]*?<body style="margin-bottom: 80px;"><script>)/i)[1] + |
| 14 | '</script><script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>' + |
| 15 | content.match(/(<div id="app">[\s\S]*?)<\/html>/i)[1].replace("${$.getEnv() || ''}", 'Node.js' + info) |
| 16 | const rewriteParser = fs.readFileSync(config[2], { encoding: 'utf8' }) |
| 17 | const ruleParser = fs.readFileSync(config[3], { encoding: 'utf8' }) |
| 18 | const scriptConverter = fs.readFileSync(config[4], { encoding: 'utf8' }) |
| 19 | return html.replace( |
| 20 | '"__SCRIPT__"', |
| 21 | JSON.stringify({ scriptConverter, rewriteParser, ruleParser, scriptMap: config[5] }) |
| 22 | ) |
| 23 | } |
| 24 | |
| 25 | if (EXPORT_HTML) { |
| 26 | // fs.rmdirSync(path.join(__dirname, './dist'), { recursive: true }) |