mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-05-06 13:32:30 +02:00
webpack update + loading prod files
This commit is contained in:
17
src/utils/getWebviewJsFiles.ts
Normal file
17
src/utils/getWebviewJsFiles.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user