File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,19 @@ class NetlifyServerPushPlugin {
2626 let mainCss = '# no css files' ;
2727
2828 const hasEsm = Object . keys ( compilation . assets ) . filter ( filename => / \. e s m \. j s $ / . test ( filename ) ) . length !== 0 ;
29- const bundleReg = hasEsm ? / ^ b u n d l e ( .+ ) \. e s m \. j s $ / : / ^ b u n d l e ( .+ ) \. j s $ / ;
3029
3130 for ( const filename in compilation . assets ) {
3231 if ( ! / \. m a p $ / . test ( filename ) ) {
3332 if ( / r o u t e - / . test ( filename ) ) {
3433 routes . push ( filename ) ;
3534 } else if ( / ^ ( s t y l e | b u n d l e ) ( .+ ) \. c s s $ / . test ( filename ) ) {
3635 mainCss = `Link: </${ filename } >; rel=preload; as=style` ;
37- } else if ( filename . match ( bundleReg ) ) {
36+ } else if ( hasEsm && / ^ b u n d l e ( .+ ) \. e s m \. j s $ / . test ( filename ) ) {
37+ mainJs = `Link: </${ filename } >; rel=preload; as=script; crossOrigin=anonymous` ;
38+ } else if ( ! hasEsm && / ^ b u n d l e ( .+ ) \. j s $ / . test ( filename ) ) {
3839 mainJs = `Link: </${ filename } >; rel=preload; as=script` ;
3940 }
40- }
41+ }
4142 }
4243
4344 let headers =
You can’t perform that action at this time.
0 commit comments