1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
const fs = require('fs') const path = require('path')
fs.readFile(path.join(__dirname, 'public', 'index.html'), (err, data) => { const htmlStr = data.toString() const resultStr = htmlStr.replace(/[\r\n]/g, '') fs.writeFile(path.join(__dirname, 'dist', 'index.html'), resultStr, err => { if (err) console.log(err) else console.log('压缩成功') }) })
|