Skip to content

Commit 16386b8

Browse files
authored
fix(examples): my-react-crasher fails to load (#6)
* fix(my-react-crasher): add base url to vite config * fix(examples): pages build with subdir
1 parent a554180 commit 16386b8

5 files changed

Lines changed: 19 additions & 13 deletions

File tree

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: npm ci
2424

2525
- name: Build Examples
26-
run: npm run build:examples
26+
run: npm run -w my-react-crasher build:pages
2727

2828
- name: Semantic Release
2929
env:

examples/my-react-crasher/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"private": true,
2323
"scripts": {
2424
"build": "vite build",
25+
"build:pages": "vite build --mode pages",
2526
"start": "vite build && npm run symbol-upload && vite preview",
2627
"symbol-upload": "env-cmd symbol-upload -d ./dist/assets",
2728
"test": "vitest"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"include": ["src", "vite.config.ts"]
3+
"include": ["src", "vite.config.ts", "vite-env.d.ts"]
44
}

examples/my-react-crasher/src/vite-env.d.ts renamed to examples/my-react-crasher/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference types="vite/client" />
2+
/// <reference types="vitest" />
23

34
interface ImportMetaEnv {
45
readonly BUGSPLAT_DATABASE?: string;
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
/// <reference types="vitest" />
1+
/// <reference types="./vite-env" />
22

33
import react from '@vitejs/plugin-react';
44
import { defineConfig } from 'vite';
55

6-
export default defineConfig({
7-
plugins: [react()],
8-
envPrefix: 'BUGSPLAT_',
9-
build: {
10-
sourcemap: true,
11-
},
12-
test: {
13-
environment: 'jsdom',
14-
include: ['./src/**/*.{test,spec}.{ts,tsx}'],
15-
},
6+
export default defineConfig(({mode}) => {
7+
return {
8+
base: mode === "pages" ? "/my-react-crasher/" : "/",
9+
plugins: [react()],
10+
envPrefix: 'BUGSPLAT_',
11+
build: {
12+
sourcemap: true,
13+
},
14+
test: {
15+
environment: 'jsdom',
16+
include: ['./src/**/*.{test,spec}.{ts,tsx}'],
17+
},
18+
}
1619
});
20+

0 commit comments

Comments
 (0)