28 lines
727 B
JavaScript
28 lines
727 B
JavaScript
|
|
import fs from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
|
||
|
|
const source = path.join('node_modules', '@flyfish-dev', 'cad-viewer', 'dist', 'wasm')
|
||
|
|
const target = path.join('public', 'wasm')
|
||
|
|
const files = [
|
||
|
|
'dwg-worker.js',
|
||
|
|
'dwfv-render.wasm',
|
||
|
|
'libredwg-web.js',
|
||
|
|
'libredwg-web.wasm'
|
||
|
|
]
|
||
|
|
|
||
|
|
if (!fs.existsSync(source)) {
|
||
|
|
console.warn(`[cad-wasm] source not found: ${source}`)
|
||
|
|
process.exit(0)
|
||
|
|
}
|
||
|
|
|
||
|
|
fs.mkdirSync(target, { recursive: true })
|
||
|
|
for (const file of files) {
|
||
|
|
const from = path.join(source, file)
|
||
|
|
if (!fs.existsSync(from)) {
|
||
|
|
console.warn(`[cad-wasm] missing: ${from}`)
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
fs.copyFileSync(from, path.join(target, file))
|
||
|
|
}
|
||
|
|
console.log(`[cad-wasm] copied ${files.length} runtime files to ${target}`)
|