1
- import type * as vscode from 'vscode'
1
+ import * as vscode from 'vscode'
2
2
import { Uri , commands } from 'vscode'
3
3
4
4
import { DiffProvider } from './diff/DiffProvider'
@@ -18,14 +18,17 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
18
18
public static readonly viewType = 'git-panel.history'
19
19
private _commits : Commit [ ] = [ ]
20
20
private _view ?: vscode . WebviewView
21
+ private _context : vscode . ExtensionContext
21
22
22
23
constructor (
23
24
private readonly _extensionUri : Uri ,
24
25
gitService : GitService ,
26
+ context : vscode . ExtensionContext ,
25
27
) {
26
28
this . gitService = gitService
27
29
this . storageService = StorageService . getInstance ( )
28
30
this . gitChangesProvider = DiffProvider . getInstance ( )
31
+ this . _context = context
29
32
this . _gitChangeMonitor = new GitChangeMonitor ( ( ) => this . refreshHistory ( true ) )
30
33
this . _commits = this . storageService . getCommits ( )
31
34
}
@@ -102,18 +105,20 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
102
105
} )
103
106
}
104
107
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
111
110
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
+ )
113
116
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
+ )
117
122
118
123
const nonce = getNonce ( )
119
124
@@ -123,6 +128,7 @@ export class GitPanelViewProvider implements vscode.WebviewViewProvider {
123
128
<meta charset="UTF-8">
124
129
<meta name="viewport" content="width=device-width, initial-scale=1.0">
125
130
<title>Git Panel</title>
131
+ ${ isDev ? '' : `<link rel="stylesheet" type="text/css" href="${ styleUri } ">` }
126
132
<style>
127
133
body {
128
134
margin: 0;
0 commit comments