Skip to content

Commit 28009a3

Browse files
authored
Merge pull request #96 from seanmarpo/main
Add support for relative path deployments
2 parents abf1ede + d8dfed6 commit 28009a3

File tree

3 files changed

+75
-67
lines changed

3 files changed

+75
-67
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "tsc -b && vite build",
8+
"preview": "vite preview",
9+
"build:pages": "tsc -b && vite build --mode pages",
10+
"preview:pages": "vite preview --mode pages",
11+
"deploy": "gh-pages -d dist",
812
"lint": "eslint .",
913
"format": "prettier --write 'src/**/*.{js,jsx,ts,tsx}'",
1014
"format:check": "prettier --check 'src/**/*.{js,jsx,ts,tsx}'",
11-
"preview": "vite preview",
12-
"knip": "knip",
13-
"deploy": "gh-pages -d dist"
15+
"knip": "knip"
1416
},
1517
"dependencies": {
1618
"@codemirror/autocomplete": "^6.18.6",

src/sqlite/core.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default class Sqlite {
3232
}
3333

3434
// Initialize SQL.js
35+
3536
private static async initSQLjs(): Promise<SqlJsStatic> {
3637
if (Sqlite.sqlJsStatic) return Sqlite.sqlJsStatic;
3738
return await initSqlJs({
@@ -156,7 +157,7 @@ export default class Sqlite {
156157
// Used for pagination
157158
private getMaxSizeOfTable(tableName: string, filters?: Filters) {
158159
const [results] = this.exec(`
159-
SELECT COUNT(*) FROM "${tableName}"
160+
SELECT COUNT(*) FROM "${tableName}"
160161
${buildWhereClause(filters)}
161162
`);
162163

@@ -175,9 +176,9 @@ export default class Sqlite {
175176
sorters?: Sorters
176177
) {
177178
const [results] = this.exec(`
178-
SELECT ${this.tablesSchema[table].primaryKey}, * FROM "${table}"
179-
${buildWhereClause(filters)}
180-
${buildOrderByClause(sorters)}
179+
SELECT ${this.tablesSchema[table].primaryKey}, * FROM "${table}"
180+
${buildWhereClause(filters)}
181+
${buildOrderByClause(sorters)}
181182
LIMIT ${limit} OFFSET ${offset}
182183
`);
183184

vite.config.ts

Lines changed: 65 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,73 @@ import compression from "vite-plugin-compression";
77
import viteImagemin from "vite-plugin-imagemin";
88
import babelReactCompiler from "babel-plugin-react-compiler";
99

10-
export default defineConfig({
11-
base: "/sqlite-online/",
12-
plugins: [
13-
react({
14-
babel: {
15-
plugins: [babelReactCompiler]
16-
}
17-
}),
18-
tailwindcss(),
19-
compression(),
20-
viteImagemin({
21-
gifsicle: {
22-
optimizationLevel: 7,
23-
interlaced: false
24-
},
25-
optipng: {
26-
optimizationLevel: 7
27-
},
28-
mozjpeg: {
29-
quality: 20
30-
},
31-
pngquant: {
32-
quality: [0.8, 0.9],
33-
speed: 4
34-
},
35-
svgo: {
36-
plugins: [
37-
{
38-
name: "removeViewBox"
39-
},
40-
{
41-
name: "removeEmptyAttrs",
42-
active: false
43-
}
44-
]
45-
}
46-
})
47-
],
48-
build: {
49-
rollupOptions: {
50-
output: {
51-
manualChunks(id) {
52-
if (id.includes("node_modules")) {
53-
return id
54-
.toString()
55-
.split("node_modules/")[1]
56-
.split("/")[0]
57-
.toString();
10+
export default defineConfig(({ mode }) => {
11+
const isPages = mode === 'pages';
12+
console.log('Mode:', mode);
13+
14+
return {
15+
base: isPages ? '/sqlite-online/' : '/',
16+
plugins: [
17+
react({
18+
babel: {
19+
plugins: [babelReactCompiler]
20+
}
21+
}),
22+
tailwindcss(),
23+
compression(),
24+
viteImagemin({
25+
gifsicle: {
26+
optimizationLevel: 7,
27+
interlaced: false
28+
},
29+
optipng: {
30+
optimizationLevel: 7
31+
},
32+
mozjpeg: {
33+
quality: 20
34+
},
35+
pngquant: {
36+
quality: [0.8, 0.9],
37+
speed: 4
38+
},
39+
svgo: {
40+
plugins: [
41+
{
42+
name: "removeViewBox"
43+
},
44+
{
45+
name: "removeEmptyAttrs",
46+
active: false
47+
}
48+
]
49+
}
50+
})
51+
],
52+
build: {
53+
rollupOptions: {
54+
output: {
55+
manualChunks(id) {
56+
if (id.includes("node_modules")) {
57+
return id
58+
.toString()
59+
.split("node_modules/")[1]
60+
.split("/")[0]
61+
.toString();
62+
}
5863
}
5964
}
6065
}
61-
}
62-
},
63-
resolve: {
64-
alias: {
65-
"@": path.resolve(__dirname, "./src")
66-
}
67-
},
68-
server: {
69-
fs: {
70-
allow: [path.resolve(__dirname), path.resolve(__dirname, "..")],
71-
strict: false
66+
},
67+
resolve: {
68+
alias: {
69+
"@": path.resolve(__dirname, "./src")
70+
}
71+
},
72+
server: {
73+
fs: {
74+
allow: [path.resolve(__dirname), path.resolve(__dirname, "..")],
75+
strict: false
76+
}
7277
}
7378
}
74-
});
79+
})

0 commit comments

Comments
 (0)