Skip to content

Commit d863b4c

Browse files
committed
Use local copy of sql.js
1 parent e4e6907 commit d863b4c

4 files changed

Lines changed: 249 additions & 2 deletions

File tree

frontend/package-lock.json

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

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@vitejs/plugin-vue": "^6.0.4",
2626
"vite": "^7.3.1",
2727
"vite-plugin-pwa": "^1.2.0",
28+
"vite-plugin-static-copy": "^3.2.0",
2829
"vite-plugin-vue-devtools": "^8.0.6"
2930
}
3031
}

frontend/src/composables/useSQLite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function useSQLite() {
2020

2121
try {
2222
SQL = await initSqlJs({
23-
locateFile: file => `https://sql.js.org/dist/${file}`
23+
locateFile: file => `/assets/wasm/${file}`
2424
});
2525
isInitialized = true
2626
}

frontend/vite.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { fileURLToPath, URL } from 'node:url'
2+
import path from 'node:path'
23

34
import { VitePWA } from 'vite-plugin-pwa'
4-
import { defineConfig, loadEnv } from 'vite'
5+
import { defineConfig, loadEnv, normalizePath } from 'vite'
6+
import { viteStaticCopy } from 'vite-plugin-static-copy'
57
import vue from '@vitejs/plugin-vue'
68

79

@@ -41,6 +43,14 @@ export default defineConfig(({ mode }) => {
4143
orientation: 'portrait',
4244
}
4345
}),
46+
viteStaticCopy({
47+
targets: [
48+
{
49+
src: normalizePath(path.resolve(__dirname, './node_modules/sql.js/dist/sql-wasm-browser.wasm')),
50+
dest: 'assets/wasm'
51+
}
52+
]
53+
}),
4454
],
4555
resolve: {
4656
alias: {

0 commit comments

Comments
 (0)