File tree Expand file tree Collapse file tree 5 files changed +25
-4
lines changed
src/commands/web/internal Expand file tree Collapse file tree 5 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ export const getSasjsTags = (parsedHtml: JSDOM) =>
66export const getScriptTags = ( parsedHtml : JSDOM ) =>
77 Array . from ( parsedHtml . window . document . getElementsByTagName ( 'script' ) )
88
9+ export const getModulePreload = ( parsedHtml : JSDOM ) =>
10+ Array . from ( parsedHtml . window . document . getElementsByTagName ( 'link' ) ) . filter (
11+ ( s ) => s . getAttribute ( 'rel' ) === 'modulepreload'
12+ )
13+
914export const getStyleInPageTags = ( parsedHtml : JSDOM ) =>
1015 Array . from ( parsedHtml . window . document . getElementsByTagName ( 'style' ) )
1116
Original file line number Diff line number Diff line change 88 getSourceTags ,
99 getStyleInPageTags ,
1010 getSasjsTags ,
11- getManifestTags
11+ getManifestTags ,
12+ getModulePreload
1213} from './getTags'
1314import { updateScriptTag } from './updateScriptTag'
1415import { updateLinkTag } from './updateLinkTag'
@@ -51,6 +52,15 @@ export const updateAllTags = async (
5152 ) . catch ( ( e ) => assetsNotFound . push ( e ) )
5253 } )
5354
55+ const modulePreloadTags = getModulePreload ( parsedHtml )
56+ modulePreloadTags . forEach ( ( tag ) => {
57+ try {
58+ updateLinkTag ( tag , assetPathMap )
59+ } catch ( error ) {
60+ assetsNotFound . push ( error as Error )
61+ }
62+ } )
63+
5464 const styleExternalTags = getStyleTags ( parsedHtml )
5565 const styleInPageTags = getStyleInPageTags ( parsedHtml )
5666 const styleTags = [ ...styleExternalTags , ...styleInPageTags ]
Original file line number Diff line number Diff line change @@ -18,7 +18,9 @@ export const updateLinkTag = (
1818
1919 const assetPath = assetPathMap . find (
2020 ( entry ) =>
21- entry . source === linkSourcePath || `./${ entry . source } ` === linkSourcePath
21+ entry . source === linkSourcePath ||
22+ `./${ entry . source } ` === linkSourcePath ||
23+ `/${ entry . source } ` === linkSourcePath
2224 )
2325
2426 if ( ! assetPath ?. target ) {
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ export const updateScriptTag = async (
5454 'src' ,
5555 assetPathMap . find (
5656 ( entry ) =>
57- entry . source === scriptPath || `./${ entry . source } ` === scriptPath
57+ entry . source === scriptPath ||
58+ `./${ entry . source } ` === scriptPath ||
59+ `/${ entry . source } ` === scriptPath
5860 ) ! . target
5961 )
6062 }
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ export const updateStyleTag = async (
5454 'href' ,
5555 assetPathMap . find (
5656 ( entry ) =>
57- entry . source === scriptPath || `./${ entry . source } ` === scriptPath
57+ entry . source === scriptPath ||
58+ `./${ entry . source } ` === scriptPath ||
59+ `/${ entry . source } ` === scriptPath
5860 ) ! . target
5961 )
6062 }
You can’t perform that action at this time.
0 commit comments