|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <html lang="en">
|
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 7 | + <title>PageSpy</title> |
| 8 | + <link rel="icon" href="/favicon.ico" /> |
| 9 | + <link rel="shortcut icon" type="image/svg+xml" href="/favicon.svg" /> |
| 10 | + <script> |
| 11 | + // Resolve the correct address from different deployment base paths. |
| 12 | + const base = location.pathname.endsWith('/') |
| 13 | + ? location.pathname.slice(0, -1) |
| 14 | + : location.pathname; |
| 15 | + // https://exp.com => 'exp.com' |
| 16 | + // https://exp.com/ => 'exp.com' |
| 17 | + // https://exp.com/page-spy => 'exp.com/page-spy' |
| 18 | + // https://exp.com/page-spy/ => 'exp.com/page-spy' |
| 19 | + window.DEPLOY_BASE_PATH = location.host + base; |
3 | 20 |
|
4 |
| -<head> |
5 |
| - <meta charset="UTF-8"> |
6 |
| - <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
7 |
| - <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
8 |
| - <title>PageSpy</title> |
9 |
| - <link rel="icon" href="/favicon.ico"> |
10 |
| - <link rel="shortcut icon" type="image/svg+xml" href="/favicon.svg"> |
11 |
| - <script src="/source-map/source-map.min.js"></script> |
12 |
| - <script> |
13 |
| - const mappingWasmUrl = new URL('/source-map/mappings.wasm', window.location.href).toString() |
14 |
| - sourceMap.SourceMapConsumer.initialize({ |
15 |
| - "lib/mappings.wasm": mappingWasmUrl |
16 |
| - }); |
17 |
| - </script> |
18 |
| - <script src="/shiki/dist/index.jsdelivr.iife.js"></script> |
19 |
| - <script> |
20 |
| - const shikiURL = new URL('/shiki', window.location.origin).toString() |
21 |
| - window.shiki.setCDN(shikiURL) |
22 |
| - </script> |
23 |
| -</head> |
| 21 | + const sourceBaseUrl = `${location.protocol}//${window.DEPLOY_BASE_PATH}`; |
24 | 22 |
|
25 |
| -<body> |
26 |
| - <div id="root"></div> |
27 |
| - <script src="/src/main.tsx" type="module"></script> |
28 |
| -</body> |
| 23 | + const loadScript = (src, cb) => { |
| 24 | + const script = document.createElement('script'); |
| 25 | + script.src = src; |
| 26 | + script.onload = () => { |
| 27 | + cb && cb(); |
| 28 | + }; |
| 29 | + document.head.appendChild(script); |
| 30 | + }; |
29 | 31 |
|
| 32 | + // source-map |
| 33 | + const sourcemapSDK = sourceBaseUrl + '/source-map/source-map.min.js'; |
| 34 | + const mappingWasmUrl = sourceBaseUrl + '/source-map/mappings.wasm'; |
| 35 | + loadScript(sourcemapSDK, () => { |
| 36 | + window.sourceMap.SourceMapConsumer.initialize({ |
| 37 | + 'lib/mappings.wasm': mappingWasmUrl, |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + // shiki |
| 42 | + const shikiSDK = sourceBaseUrl + '/shiki/dist/index.jsdelivr.iife.js'; |
| 43 | + const shikiCDN = sourceBaseUrl + '/shiki'; |
| 44 | + loadScript(shikiSDK, () => { |
| 45 | + window.shiki.setCDN(shikiCDN); |
| 46 | + }); |
| 47 | + </script> |
| 48 | + </head> |
| 49 | + |
| 50 | + <body> |
| 51 | + <div id="root"></div> |
| 52 | + <script src="/src/main.tsx" type="module"></script> |
| 53 | + </body> |
30 | 54 | </html>
|
0 commit comments