@@ -128,16 +128,18 @@ class ReactWebView {
128128
129129 const manifest = require ( path . join ( this . extensionPath , 'build' , 'asset-manifest.json' ) )
130130
131- const mainStyle = manifest . files [ 'main.css' ]
132- const stylePathOnDisk = vscode . Uri . file ( path . join ( this . extensionPath , 'build' , mainStyle ) )
133- const styleUri = stylePathOnDisk . with ( { scheme : 'vscode-resource' } )
134-
135131 const getSrc = ( manifestName : string ) : any => {
136132 const file = manifest . files [ manifestName ]
137133 const uriPath = vscode . Uri . file ( path . join ( this . extensionPath , 'build' , file ) )
138134 return uriPath . with ( { scheme : 'vscode-resource' } )
139135 }
140136
137+ const styles = [
138+ 'main.css' ,
139+ // get style chunk
140+ Object . keys ( manifest . files ) . find ( f => f . match ( / ^ s t a t i c \/ c s s \/ .+ \. c s s $ / ) ) || ''
141+ ] . map ( style => getSrc ( style ) )
142+
141143 // map over scripts
142144 const scripts = [ {
143145 file : './webpackBuild.js' ,
@@ -146,8 +148,8 @@ class ReactWebView {
146148 } , {
147149 manifest : 'main.js' ,
148150 } , {
149- // grab first file that matches chunk
150- manifest : Object . keys ( manifest . files ) . filter ( f => f . match ( / ^ s t a t i c \/ j s \/ .+ \. j s $ / ) ) [ 0 ] ,
151+ // get js chunk
152+ manifest : Object . keys ( manifest . files ) . find ( f => f . match ( / ^ s t a t i c \/ j s \/ .+ \. j s $ / ) ) ,
151153 } ] . map ( script => ( {
152154 nonce : getNonce ( ) ,
153155 src : script . manifest ? getSrc ( script . manifest ) : script . file
@@ -165,7 +167,7 @@ class ReactWebView {
165167
166168 <!-- TODO: load styles through package -->
167169 <!-- <link rel='stylesheet' href='https://unpkg.com/@alifd/next/dist/next.css' /> -->
168- <!-- <link rel='stylesheet' type='text/css' href='${ styleUri } '> -->
170+ ${ styles . map ( styleUri => ` <link rel='stylesheet' type='text/css' href='${ styleUri } '>` ) . join ( '\n' ) }
169171
170172 <meta http-equiv='Content-Security-Policy' content="font-src *; img-src vscode-resource: https:; script-src ${ scripts . map ( script => `'nonce-${ script . nonce } '` ) . join ( ' ' ) } ; style-src vscode-resource: 'unsafe-inline' http: https: data:;">
171173 <base href='${ buildUri } /'>
0 commit comments