Skip to content

Commit d0828e4

Browse files
authoredOct 7, 2024
fix(chrome-129): show issue page (stackblitz#157)
1 parent efcb93d commit d0828e4

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
"rehype-raw": "^7.0.0",
7272
"rehype-sanitize": "^6.0.0",
7373
"remark-gfm": "^4.0.0",
74+
"remix-island": "^0.2.0",
7475
"remix-utils": "^7.6.0",
7576
"shiki": "^1.9.1",
76-
"remix-island": "^0.2.0",
7777
"unist-util-visit": "^5.0.0"
7878
},
7979
"devDependencies": {

‎vite.config.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cloudflareDevProxyVitePlugin as remixCloudflareDevProxy, vitePlugin as remixVitePlugin } from '@remix-run/dev';
22
import UnoCSS from 'unocss/vite';
3-
import { defineConfig } from 'vite';
3+
import { defineConfig, type ViteDevServer } from 'vite';
44
import { nodePolyfills } from 'vite-plugin-node-polyfills';
55
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
66
import tsconfigPaths from 'vite-tsconfig-paths';
@@ -24,7 +24,34 @@ export default defineConfig((config) => {
2424
}),
2525
UnoCSS(),
2626
tsconfigPaths(),
27+
chrome129IssuePlugin(),
2728
config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
2829
],
2930
};
3031
});
32+
33+
function chrome129IssuePlugin() {
34+
return {
35+
name: 'chrome129IssuePlugin',
36+
configureServer(server: ViteDevServer) {
37+
server.middlewares.use((req, res, next) => {
38+
const raw = req.headers['user-agent']?.match(/Chrom(e|ium)\/([0-9]+)\./);
39+
40+
if (raw) {
41+
const version = parseInt(raw[2], 10);
42+
43+
if (version === 129) {
44+
res.setHeader('content-type', 'text/html');
45+
res.end(
46+
'<body><h1>Please use Chrome Canary for testing.</h1><p>Chrome 129 has an issue with JavaScript modules & Vite local development, see <a href="https://github.com/stackblitz/bolt.new/issues/86#issuecomment-2395519258">for more information.</a></p><p><b>Note:</b> This only impacts <u>local development</u>. `pnpm run build` and `pnpm run start` will work fine in this browser.</p></body>',
47+
);
48+
49+
return;
50+
}
51+
}
52+
53+
next();
54+
});
55+
},
56+
};
57+
}

0 commit comments

Comments
 (0)