From 63630ef5e788208be0ab5b7476c9f271e4c9e385 Mon Sep 17 00:00:00 2001 From: Rankin Zheng Date: Sat, 6 May 2023 17:32:01 +0800 Subject: [PATCH] Refactor file structure Rename src/views to src and move index.html and index.tsx to the root directory. --- src/{views => }/index.html | 0 src/{views => }/index.tsx | 2 +- src/panel/webviewManager.ts | 1 + webpack.config.js | 4 ++-- 4 files changed, 4 insertions(+), 3 deletions(-) rename src/{views => }/index.html (100%) rename src/{views => }/index.tsx (92%) diff --git a/src/views/index.html b/src/index.html similarity index 100% rename from src/views/index.html rename to src/index.html diff --git a/src/views/index.tsx b/src/index.tsx similarity index 92% rename from src/views/index.tsx rename to src/index.tsx index 54ac565..6db9453 100644 --- a/src/views/index.tsx +++ b/src/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { createRoot } from 'react-dom/client'; import { MantineProvider } from '@mantine/core'; -import App from './App'; +import App from './views/App'; const container = document.getElementById('app')!; const root = createRoot(container); // createRoot(container!) if you use TypeScript diff --git a/src/panel/webviewManager.ts b/src/panel/webviewManager.ts index a8c7b5f..890e650 100644 --- a/src/panel/webviewManager.ts +++ b/src/panel/webviewManager.ts @@ -26,6 +26,7 @@ export default class WebviewManager { private _getHtmlContent(): string { const htmlPath = vscode.Uri.joinPath(this._extensionUri, 'dist', 'assets', 'chatPanel.html'); + // const htmlPath = vscode.Uri.joinPath(this._extensionUri, 'dist', 'index.html'); const htmlContent = fs.readFileSync(htmlPath.fsPath, 'utf8'); return htmlContent.replace(//g, (_, resourcePath) => { diff --git a/webpack.config.js b/webpack.config.js index 09d0a1d..2c690e3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -69,7 +69,7 @@ const webviewConfig = { target: 'web', mode: 'development', - entry: './src/views/index.tsx', + entry: './src/index.tsx', output: { path: path.resolve(__dirname, 'dist'), filename: 'index.js', @@ -155,7 +155,7 @@ const webviewConfig = { plugins: [ // generate an HTML file that includes the extension's JavaScript file new HtmlWebpackPlugin({ - template: path.resolve(__dirname, 'src', 'views', 'index.html'), + template: path.resolve(__dirname, 'src', 'index.html'), filename: 'index.html', chunks: ['index'] }),