1- import type * as vscode from 'vscode'
1+ import * as vscode from 'vscode'
22import { Uri , commands } from 'vscode'
33
44import { DiffProvider } from './diff/DiffProvider'
@@ -18,14 +18,17 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
1818 public static readonly viewType = 'git-panel.history'
1919 private _commits : Commit [ ] = [ ]
2020 private _view ?: vscode . WebviewView
21+ private _context : vscode . ExtensionContext
2122
2223 constructor (
2324 private readonly _extensionUri : Uri ,
2425 gitService : GitService ,
26+ context : vscode . ExtensionContext ,
2527 ) {
2628 this . gitService = gitService
2729 this . storageService = StorageService . getInstance ( )
2830 this . gitChangesProvider = DiffProvider . getInstance ( )
31+ this . _context = context
2932 this . _gitChangeMonitor = new GitChangeMonitor ( ( ) => this . refreshHistory ( true ) )
3033 this . _commits = this . storageService . getCommits ( )
3134 }
@@ -102,18 +105,20 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
102105 } )
103106 }
104107
105- private _getHtmlForWebview ( _webview : vscode . Webview ) {
106- // const scriptUri = process.env.NODE_ENV === 'development'
107- // ? 'http://localhost:5173/src/views/history/index.ts'
108- // : webview.asWebviewUri(
109- // Uri.joinPath(this._extensionUri, 'views.es.js'),
110- // )
108+ private _getHtmlForWebview ( webview : vscode . Webview ) {
109+ const isDev = this . _context . extensionMode === vscode . ExtensionMode . Development
111110
112- const scriptUri = 'http://localhost:5173/src/views/history/index.ts'
111+ const scriptUri = isDev
112+ ? 'http://localhost:5173/src/views/history/index.ts'
113+ : webview . asWebviewUri (
114+ Uri . joinPath ( this . _extensionUri , 'views.es.js' ) ,
115+ )
113116
114- // const styleUri = webview.asWebviewUri(
115- // Uri.joinPath(this._extensionUri, 'views.css'),
116- // )
117+ const styleUri = isDev
118+ ? null
119+ : webview . asWebviewUri (
120+ Uri . joinPath ( this . _extensionUri , 'views.css' ) ,
121+ )
117122
118123 const nonce = getNonce ( )
119124
@@ -123,6 +128,7 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
123128 <meta charset="UTF-8">
124129 <meta name="viewport" content="width=device-width, initial-scale=1.0">
125130 <title>Git Panel</title>
131+ ${ isDev ? '' : `<link rel="stylesheet" type="text/css" href="${ styleUri } ">` }
126132 <style>
127133 body {
128134 margin: 0;
0 commit comments