1 | import { dirname } from 'path'
|
2 | import { promises as fs } from 'fs'
|
3 |
|
4 | export default async function prepack(node) {
|
5 | for (const key in node.children) {
|
6 | const child = node.children[key]
|
7 |
|
8 | if (child.isDirectory) await prepack(child)
|
9 | else {
|
10 | const dest = child.prepackPath.replace('.html', '.js')
|
11 |
|
12 | await fs.mkdir(dirname(dest), { recursive: true })
|
13 | await fs.writeFile(dest, child.js)
|
14 | }
|
15 | }
|
16 | }
|