Skip to content

Commit

Permalink
fix(unreleased): use pathkit's locateFile option instead of vite-plug…
Browse files Browse the repository at this point in the history
…in-static-copy to load wasm
  • Loading branch information
MichaelMakesGames committed Nov 1, 2024
1 parent 0588992 commit db23a5c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 71 deletions.
56 changes: 1 addition & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.4.5",
"utility-types": "^3.11.0",
"vite": "^5.2.8",
"vite-plugin-static-copy": "^2.0.0"
"vite": "^5.2.8"
},
"dependencies": {
"@electron-toolkit/preload": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/customTypings/pathkit-wasm.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// only the types used are implemented
// see https://skia.org/docs/user/modules/pathkit/#api for more
declare module 'pathkit-wasm/bin/pathkit' {
function PathKitInit(): Promise<PathKit>;
function PathKitInit(options?: { locateFile: (file: string) => string }): Promise<PathKit>;

export interface PathKit {
NewPath(): SkPath;
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/lib/pathKit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PathKitInit from 'pathkit-wasm/bin/pathkit';
import pathKitWasm from 'pathkit-wasm/bin/pathkit.wasm?url';

export const pathKitPromise = PathKitInit();
export const pathKitPromise = PathKitInit({ locateFile: () => pathKitWasm });
13 changes: 1 addition & 12 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';

export default defineConfig({
plugins: [
svelte({ configFile: '../../svelte.config.mjs' }),
viteStaticCopy({
targets: [
{
src: '../../node_modules/pathkit-wasm/bin/pathkit.wasm',
dest: '/',
},
],
}),
],
plugins: [svelte({ configFile: '../../svelte.config.mjs' })],
root: 'src/renderer',
build: {
outDir: '../../build',
Expand Down

0 comments on commit db23a5c

Please sign in to comment.