Skip to content

Commit e8e0019

Browse files
committed
fix: crash on no build
1 parent ed58679 commit e8e0019

File tree

3 files changed

+228
-116
lines changed

3 files changed

+228
-116
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@
3232
"nodemon": "^2.0.20",
3333
"react": "^18.2.0",
3434
"react-dom": "^18.2.0",
35-
"react-router-dom": "^6.4.5",
35+
"react-router-dom": "^6.6.1",
3636
"serve-static": "^1.15.0",
3737
"ts-node": "^10.9.1"
3838
},
3939
"devDependencies": {
40-
"@types/express": "^4.17.14",
40+
"@types/express": "^4.17.15",
4141
"@testing-library/jest-dom": "^5.16.5",
4242
"@testing-library/react": "^13.4.0",
4343
"@types/compression": "1.7.2",
4444
"@types/concurrently": "6.4.0",
4545
"@types/eslint": "8.4.10",
46-
"@types/node": "18.11.13",
46+
"@types/node": "18.11.18",
4747
"@types/react": "^18.0.26",
48-
"@types/react-dom": "^18.0.9",
48+
"@types/react-dom": "^18.0.10",
4949
"@types/react-router-dom": "^5.3.3",
50-
"@typescript-eslint/eslint-plugin": "^5.46.1",
51-
"@typescript-eslint/parser": "^5.46.1",
50+
"@typescript-eslint/eslint-plugin": "^5.48.0",
51+
"@typescript-eslint/parser": "^5.48.0",
5252
"@vitejs/plugin-react": "^3.0.0",
5353
"concurrently": "7.6.0",
5454
"copyfiles": "^2.4.1",
55-
"eslint": "^8.29.0",
56-
"eslint-config-prettier": "^8.5.0",
55+
"eslint": "^8.31.0",
56+
"eslint-config-prettier": "^8.6.0",
5757
"eslint-config-standard": "^17.0.0",
5858
"eslint-plugin-react": "^7.31.11",
5959
"eslint-plugin-react-hooks": "^4.6.0",
@@ -63,7 +63,7 @@
6363
"rimraf": "^3.0.2",
6464
"tailwindcss": "3.2.4",
6565
"typescript": "4.9.4",
66-
"vite": "4.0.1",
67-
"vitest": "^0.25.7"
66+
"vite": "4.0.3",
67+
"vitest": "^0.26.3"
6868
}
6969
}

server.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ const isTest = process.env.NODE_ENV === "test" || !!process.env.VITE_TEST_BUILD;
1010
const resolve = (p: string) => path.resolve(__dirname, p);
1111

1212
const getStyleSheets = async () => {
13-
const assetpath = resolve("dist/assets");
14-
const files = await fs.readdir(assetpath);
15-
const cssAssets = files.filter(l => l.endsWith(".css"));
16-
const allContent = [];
17-
for (const asset of cssAssets) {
18-
const content = await fs.readFile(path.join(assetpath, asset), "utf-8");
19-
allContent.push(`<style type="text/css">${content}</style>`);
13+
try {
14+
const assetpath = resolve("dist/assets");
15+
const files = await fs.readdir(assetpath);
16+
const cssAssets = files.filter(l => l.endsWith(".css"));
17+
const allContent = [];
18+
for (const asset of cssAssets) {
19+
const content = await fs.readFile(path.join(assetpath, asset), "utf-8");
20+
allContent.push(`<style type="text/css">${content}</style>`);
21+
}
22+
return allContent.join("\n");
23+
} catch {
24+
return "";
2025
}
21-
return allContent.join("\n");
2226
};
2327

2428
async function createServer(isProd = process.env.NODE_ENV === "production") {

0 commit comments

Comments
 (0)