@@ -38,7 +38,7 @@ export class WebPanel implements IWebPanel {
3838 {
3939 enableScripts : true ,
4040 retainContextWhenHidden : true ,
41- localResourceRoots : [ Uri . file ( this . options . rootPath ) ] ,
41+ localResourceRoots : [ Uri . file ( this . options . rootPath ) , Uri . file ( this . options . cwd ) ] ,
4242 enableFindWidget : true ,
4343 portMapping : port ? [ { webviewPort : RemappedPort , extensionHostPort : port } ] : undefined
4444 }
@@ -129,19 +129,21 @@ export class WebPanel implements IWebPanel {
129129
130130 // tslint:disable-next-line:no-any
131131 private generateLocalReactHtml ( webView : Webview ) {
132- const uriBase = webView . asWebviewUri ( Uri . file ( this . options . rootPath ) ) ;
132+ const uriBase = webView . asWebviewUri ( Uri . file ( this . options . cwd ) ) . toString ( ) ;
133133 const uris = this . options . scripts . map ( script => webView . asWebviewUri ( Uri . file ( script ) ) ) ;
134134
135135 return `<!doctype html>
136136 <html lang="en">
137137 <head>
138138 <meta charset="utf-8">
139139 <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
140- <meta http-equiv="Content-Security-Policy" content="img-src 'self' data: https: http: blob:; default-src 'unsafe-inline' 'unsafe-eval' vscode-resource: data: https: http: blob:;">
140+ <meta http-equiv="Content-Security-Policy" content="img-src 'self' data: https: http: blob: ${
141+ webView . cspSource
142+ } ; default-src 'unsafe-inline' 'unsafe-eval' vscode-resource: data: https: http: blob:;">
141143 <meta name="theme-color" content="#000000">
142144 <meta name="theme" content="${ Identifiers . GeneratedThemeName } "/>
143145 <title>React App</title>
144- <base href="${ uriBase } "/>
146+ <base href="${ uriBase } ${ uriBase . endsWith ( '/' ) ? '' : '/' } "/>
145147 </head>
146148 <body>
147149 <noscript>You need to enable JavaScript to run this app.</noscript>
0 commit comments