20 lines
692 B
JavaScript
20 lines
692 B
JavaScript
import { copyFile, mkdir, rm } from 'node:fs/promises'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const files = ['index.html', 'assets/admin-app.css', 'assets/admin-app.js']
|
|
const root = new URL('../', import.meta.url)
|
|
const appRoot = new URL('./app/', root)
|
|
const distRoot = new URL('./dist/', root)
|
|
|
|
await rm(distRoot, { recursive: true, force: true })
|
|
|
|
for (const file of files) {
|
|
const source = new URL(file, appRoot)
|
|
const target = new URL(file, distRoot)
|
|
await mkdir(dirname(fileURLToPath(target)), { recursive: true })
|
|
await copyFile(source, target)
|
|
}
|
|
|
|
console.log(`Built ${files.length} files to ${join(fileURLToPath(root), 'dist')}`)
|