mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	refactor: use static as the asset dir name (#1586)
* refactor: use static as the asset dir name * chore: update unleash-frontend * refactor: use the real index.html in tests
This commit is contained in:
		
							parent
							
								
									3b46bfb83a
								
							
						
					
					
						commit
						3bea8a9931
					
				| @ -116,7 +116,7 @@ | ||||
|     "stoppable": "^1.1.0", | ||||
|     "type-is": "^1.6.18", | ||||
|     "@unleash/express-openapi": "^0.2.0", | ||||
|     "unleash-frontend": "4.11.0-beta.0", | ||||
|     "unleash-frontend": "4.11.0-beta.1", | ||||
|     "uuid": "^8.3.2", | ||||
|     "semver": "^7.3.5" | ||||
|   }, | ||||
|  | ||||
| @ -1,32 +1,9 @@ | ||||
| import fs from 'fs'; | ||||
| import path from 'path'; | ||||
| import { rewriteHTML } from './rewriteHTML'; | ||||
| import { publicFolder } from 'unleash-frontend'; | ||||
| 
 | ||||
| const input = ` | ||||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
|     <head> | ||||
|         <meta charset="utf-8" /> | ||||
|         <link rel="icon" href="::faviconPrefix::/favicon.ico" /> | ||||
|         <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||||
|         <meta name="baseUriPath" content="::baseUriPath::" /> | ||||
|         <meta name="cdnPrefix" content="::cdnPrefix::" /> | ||||
|         <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||||
|         <meta name="description" content="unleash" /> | ||||
|         <title>Unleash</title> | ||||
|         <link rel="preconnect" href="https://fonts.googleapis.com" /> | ||||
|         <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||||
|         <link | ||||
|             href="https://fonts.googleapis.com/css2?family=Sen:wght@400;700;800&display=swap" | ||||
|             rel="stylesheet" | ||||
|         /> | ||||
|       <script type="module" crossorigin src="/assets/index.556ac563.js"></script> | ||||
|       <link rel="stylesheet" href="/assets/index.4b6b260a.css"> | ||||
|     </head> | ||||
|     <body> | ||||
|         <div id="app"></div> | ||||
| 
 | ||||
|     </body> | ||||
| </html> | ||||
| `;
 | ||||
| const input = fs.readFileSync(path.join(publicFolder, 'index.html')).toString(); | ||||
| 
 | ||||
| test('rewriteHTML substitutes meta tag with existing rewrite value', () => { | ||||
|     const result = rewriteHTML(input, '/hosted'); | ||||
| @ -46,7 +23,7 @@ test('rewriteHTML substitutes asset paths correctly with baseUriPath', () => { | ||||
|     const result = rewriteHTML(input, '/hosted'); | ||||
|     expect( | ||||
|         result.includes( | ||||
|             '<script type="module" crossorigin src="/hosted/assets/index', | ||||
|             '<script type="module" crossorigin src="/hosted/static/index', | ||||
|         ), | ||||
|     ).toBe(true); | ||||
| }); | ||||
| @ -54,7 +31,7 @@ test('rewriteHTML substitutes asset paths correctly with baseUriPath', () => { | ||||
| test('rewriteHTML substitutes asset paths correctly without baseUriPath', () => { | ||||
|     const result = rewriteHTML(input, ''); | ||||
|     expect( | ||||
|         result.includes('<script type="module" crossorigin src="/assets/index'), | ||||
|         result.includes('<script type="module" crossorigin src="/static/index'), | ||||
|     ).toBe(true); | ||||
| }); | ||||
| 
 | ||||
| @ -62,7 +39,7 @@ test('rewriteHTML substitutes asset paths correctly with cdnPrefix', () => { | ||||
|     const result = rewriteHTML(input, '', 'https://cdn.getunleash.io/v4.1.0'); | ||||
|     expect( | ||||
|         result.includes( | ||||
|             '<script type="module" crossorigin src="https://cdn.getunleash.io/v4.1.0/assets/index', | ||||
|             '<script type="module" crossorigin src="https://cdn.getunleash.io/v4.1.0/static/index', | ||||
|         ), | ||||
|     ).toBe(true); | ||||
| }); | ||||
|  | ||||
| @ -11,8 +11,8 @@ export const rewriteHTML = ( | ||||
|     result = result.replace(/::faviconPrefix::/gi, faviconPrefix); | ||||
| 
 | ||||
|     result = result.replace( | ||||
|         /\/assets/gi, | ||||
|         `${cdnPrefix || rewriteValue}/assets`, | ||||
|         /\/static/gi, | ||||
|         `${cdnPrefix || rewriteValue}/static`, | ||||
|     ); | ||||
| 
 | ||||
|     return result; | ||||
|  | ||||
| @ -7466,10 +7466,10 @@ universalify@^2.0.0: | ||||
|   resolved "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz" | ||||
|   integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== | ||||
| 
 | ||||
| unleash-frontend@4.11.0-beta.0: | ||||
|   version "4.11.0-beta.0" | ||||
|   resolved "https://registry.yarnpkg.com/unleash-frontend/-/unleash-frontend-4.11.0-beta.0.tgz#1e48bf66f15a4999c8efab19d214a975858ede7d" | ||||
|   integrity sha512-yNKzjGXUXPZgp+ihGdYphiDgeOzxN2mAslJnvFnGh15c7B2MBYeflf1DaHihcdwJTxhJsEucxE6cRucH/2DQOA== | ||||
| unleash-frontend@4.11.0-beta.1: | ||||
|   version "4.11.0-beta.1" | ||||
|   resolved "https://registry.yarnpkg.com/unleash-frontend/-/unleash-frontend-4.11.0-beta.1.tgz#b93245488b5d8a143c8e17728e27b6005b917754" | ||||
|   integrity sha512-CSTG+mJyxxlNEBlGPzRxP8ExwbtFjE9IyB1JGV3X7YpsWXQDOxspB2/PZLUL0yAZhUrtbcg2I2hHhbp8ehVdCQ== | ||||
| 
 | ||||
| unpipe@1.0.0, unpipe@~1.0.0: | ||||
|   version "1.0.0" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user