vscode extension. 'JS Import' from webview

Viewed 950

I'm write extension for vscode with webview as single web application. My project has the following structure: enter image description here

In index html I want to import a script.

<script type="module">
import * as CommandHandler from '/core/CommandHadnler.js'
//some code
</script>

WebView setup localResourceRoots

const UI_PATH = path.join(context.extensionPath, 'UI');
this._panel = vscode.window.createWebviewPanel(
    'JSONRPCTester',
    'JSONRPC Tester',
    vscode.ViewColumn.Two,
    {
        enableScripts: true,
        localResourceRoots: [
           vscode.Uri.file(UI_PATH)
        ]
    } 
 );

I see that there is an attempt to load the module, but I get the error (Ignore RPC* ). enter image description here

load url:

vscode-webview://a8f78cdc-7d22-4793-810f-67c2d10dfb67/core/ClientProxy.js

Probably it incorrect Content Security Policy. My policy setup:

<meta http-equiv="Content-Security-Policy" content="default-src self; img-src vscode-webview-resource:; script-src vscode-webview-resource: 'self' 'unsafe-inline'; style-src vscode-webview-resource: 'self' 'unsafe-inline'; ">
1 Answers
Related