Sam Denty
commited on
fix(chrome-129): show issue page (#157)
Browse files- package.json +1 -1
- vite.config.ts +28 -1
package.json
CHANGED
|
@@ -71,9 +71,9 @@
|
|
| 71 |
"rehype-raw": "^7.0.0",
|
| 72 |
"rehype-sanitize": "^6.0.0",
|
| 73 |
"remark-gfm": "^4.0.0",
|
|
|
|
| 74 |
"remix-utils": "^7.6.0",
|
| 75 |
"shiki": "^1.9.1",
|
| 76 |
-
"remix-island": "^0.2.0",
|
| 77 |
"unist-util-visit": "^5.0.0"
|
| 78 |
},
|
| 79 |
"devDependencies": {
|
|
|
|
| 71 |
"rehype-raw": "^7.0.0",
|
| 72 |
"rehype-sanitize": "^6.0.0",
|
| 73 |
"remark-gfm": "^4.0.0",
|
| 74 |
+
"remix-island": "^0.2.0",
|
| 75 |
"remix-utils": "^7.6.0",
|
| 76 |
"shiki": "^1.9.1",
|
|
|
|
| 77 |
"unist-util-visit": "^5.0.0"
|
| 78 |
},
|
| 79 |
"devDependencies": {
|
vite.config.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import { cloudflareDevProxyVitePlugin as remixCloudflareDevProxy, vitePlugin as remixVitePlugin } from '@remix-run/dev';
|
| 2 |
import UnoCSS from 'unocss/vite';
|
| 3 |
-
import { defineConfig } from 'vite';
|
| 4 |
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
| 5 |
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
|
| 6 |
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
@@ -24,7 +24,34 @@ export default defineConfig((config) => {
|
|
| 24 |
}),
|
| 25 |
UnoCSS(),
|
| 26 |
tsconfigPaths(),
|
|
|
|
| 27 |
config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
|
| 28 |
],
|
| 29 |
};
|
| 30 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import { cloudflareDevProxyVitePlugin as remixCloudflareDevProxy, vitePlugin as remixVitePlugin } from '@remix-run/dev';
|
| 2 |
import UnoCSS from 'unocss/vite';
|
| 3 |
+
import { defineConfig, type ViteDevServer } from 'vite';
|
| 4 |
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
| 5 |
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
|
| 6 |
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
| 24 |
}),
|
| 25 |
UnoCSS(),
|
| 26 |
tsconfigPaths(),
|
| 27 |
+
chrome129IssuePlugin(),
|
| 28 |
config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
|
| 29 |
],
|
| 30 |
};
|
| 31 |
});
|
| 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 |
+
}
|