Skip to content

Commit 4402f84

Browse files
Copy wasm blob
1 parent e3ba6cd commit 4402f84

File tree

3 files changed

+25
-33
lines changed

3 files changed

+25
-33
lines changed

package-lock.json

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"@rollup/plugin-node-resolve": "15.2.3",
1616
"@rollup/plugin-terser": "0.4.4",
1717
"@rollup/plugin-typescript": "11.1.5",
18-
"@rollup/plugin-wasm": "6.2.2",
1918
"@tsconfig/svelte": "5.0.2",
2019
"@types/human-date": "^1.4.0",
2120
"autoprefixer": "10.4.13",

rollup.config.mjs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,36 @@ import css from 'rollup-plugin-css-only';
66
import livereload from 'rollup-plugin-livereload';
77
import svelte from 'rollup-plugin-svelte';
88
import terser from '@rollup/plugin-terser';
9-
import wasm from '@rollup/plugin-wasm';
109
import sveltePreprocess from 'svelte-preprocess';
1110
import tailwindcss from 'tailwindcss';
1211
import { spawn } from 'child_process'
12+
import fs from 'fs/promises'
13+
import path from 'path'
1314

1415
const production = !process.env.ROLLUP_WATCH;
1516

17+
const wasmFiles = [
18+
'node_modules/nz-search/nz_search_bg.wasm'
19+
]
20+
21+
function copyBlobsPlugin() {
22+
return {
23+
name: 'copy-wasm-blobs',
24+
async buildEnd() {
25+
for (const wasmBlob of wasmFiles) {
26+
const data = await fs.readFile(path.resolve(wasmBlob))
27+
await this.emitFile({
28+
type: 'asset',
29+
source: data,
30+
fileName: path.basename(wasmBlob)
31+
32+
})
33+
this.addWatchFile(wasmBlob)
34+
}
35+
}
36+
}
37+
}
38+
1639
function serve() {
1740
let server;
1841

@@ -59,7 +82,7 @@ export default {
5982
}),
6083
}),
6184

62-
wasm(),
85+
copyBlobsPlugin(),
6386

6487
css({ output: "extra.css" }),
6588

0 commit comments

Comments
 (0)