Skip to content

Commit 3749e17

Browse files
committed
Bundle Codicons using Webpack
This will include the Codicons inside the webview bundle, reducing the number of files that need to be loaded and the resource roots that need to be included.
1 parent de6c523 commit 3749e17

File tree

6 files changed

+125
-18
lines changed

6 files changed

+125
-18
lines changed

extensions/ql-vscode/gulpfile.ts/webpack.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ export const config: webpack.Configuration = {
5555
loader: 'css-loader'
5656
}
5757
]
58+
},
59+
{
60+
test: /\.(woff(2)?|ttf|eot|svg)$/,
61+
use: [
62+
{
63+
loader: 'file-loader',
64+
options: {
65+
name: '[name].[ext]',
66+
outputPath: 'fonts/',
67+
esModule: false
68+
}
69+
},
70+
],
5871
}
5972
]
6073
},

extensions/ql-vscode/package-lock.json

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ql-vscode/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,7 @@
12821282
"del": "^6.0.0",
12831283
"eslint": "~6.8.0",
12841284
"eslint-plugin-react": "~7.19.0",
1285+
"file-loader": "^6.2.0",
12851286
"glob": "^7.1.4",
12861287
"gulp": "^4.0.2",
12871288
"gulp-replace": "^1.1.3",

extensions/ql-vscode/src/interface-utils.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,11 @@ export function getHtmlForWebview(
121121
webview: Webview,
122122
view: 'results' | 'compare' | 'remote-queries',
123123
{
124-
allowInlineStyles,
125-
includeCodicons
124+
allowInlineStyles
126125
}: {
127126
allowInlineStyles?: boolean;
128-
includeCodicons?: boolean;
129127
} = {
130-
allowInlineStyles: false,
131-
includeCodicons: false
128+
allowInlineStyles: false
132129
}
133130
): string {
134131
const scriptUriOnDisk = Uri.file(
@@ -139,16 +136,6 @@ export function getHtmlForWebview(
139136
Uri.file(ctx.asAbsolutePath('out/webview.css'))
140137
];
141138

142-
if (includeCodicons) {
143-
// Allows use of the VS Code "codicons" icon set.
144-
// See https://github.com/microsoft/vscode-codicons
145-
const codiconsPathOnDisk = Uri.file(
146-
ctx.asAbsolutePath('node_modules/@vscode/codicons/dist/codicon.css')
147-
);
148-
149-
stylesheetUrisOnDisk.push(codiconsPathOnDisk);
150-
}
151-
152139
// Convert the on-disk URIs into webview URIs.
153140
const scriptWebviewUri = webview.asWebviewUri(scriptUriOnDisk);
154141
const stylesheetWebviewUris = stylesheetUrisOnDisk.map(stylesheetUriOnDisk =>

extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ export class RemoteQueriesInterfaceManager {
116116
retainContextWhenHidden: true,
117117
localResourceRoots: [
118118
Uri.file(this.analysesResultsManager.storagePath),
119-
Uri.file(path.join(this.ctx.extensionPath, 'out')),
120-
Uri.file(path.join(this.ctx.extensionPath, 'node_modules/@vscode/codicons/dist')),
119+
Uri.file(path.join(this.ctx.extensionPath, 'out'))
121120
],
122121
}
123122
));
@@ -136,7 +135,6 @@ export class RemoteQueriesInterfaceManager {
136135
panel.webview,
137136
'remote-queries',
138137
{
139-
includeCodicons: true,
140138
allowInlineStyles: true,
141139
}
142140
);

extensions/ql-vscode/src/view/webview.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { vscode } from './vscode-api';
33

44
import { WebviewDefinition } from './webview-interface';
55

6+
// Allow all views to use Codicons
7+
import '@vscode/codicons/dist/codicon.css';
8+
69
const render = () => {
710
const element = document.getElementById('root');
811

0 commit comments

Comments
 (0)