File size: 638 Bytes
f6c1709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const staticDir = path.resolve(__dirname, '../../static')
const assetsDir = path.join(staticDir, 'assets')
const indexFile = path.join(staticDir, 'index.html')

function safeRemove(targetPath) {
  if (!fs.existsSync(targetPath)) {
    return
  }
  fs.rmSync(targetPath, { recursive: true, force: true })
}

safeRemove(assetsDir)
safeRemove(indexFile)

fs.mkdirSync(staticDir, { recursive: true })
console.log(`[clean-static] cleaned: ${assetsDir}`)