webpack update + loading prod files

This commit is contained in:
Elio Struyf
2024-09-19 12:57:39 +02:00
parent 0110b7365c
commit b9508df4f8
10 changed files with 167 additions and 57 deletions

View File

@@ -0,0 +1,17 @@
import { readFileAsync } from './readFileAsync';
import { Uri, Webview } from 'vscode';
import { Extension } from '../helpers';
export const getWebviewJsFiles = async (name: string, webview: Webview) => {
const context = Extension.getInstance();
const extensionPath = context.extensionPath;
const webviewFolder = Uri.joinPath(extensionPath, 'dist');
const manifestPath = Uri.joinPath(webviewFolder, `${name}.manifest.json`);
const manifest = await readFileAsync(manifestPath.fsPath, 'utf8');
const manifestJson = JSON.parse(manifest);
const entries = Object.entries<string>(manifestJson).filter(([key]) => key.endsWith('.js'));
const files = entries.map(([_, value]) =>
webview.asWebviewUri(Uri.joinPath(webviewFolder, value)).toString()
);
return files;
};