From 712990658befb56c176c25ce3173b2f9e3c32c54 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 21 Feb 2022 00:20:10 -0500 Subject: [PATCH] Improves loading performance of webviews --- src/webviews/apps/home/home.html | 13 +- src/webviews/apps/home/home.ts | 8 + src/webviews/apps/rebase/rebase.html | 12 +- src/webviews/apps/settings/partials/blame.html | 8 + src/webviews/apps/settings/partials/changes.html | 4 +- src/webviews/apps/settings/partials/code-lens.html | 11 +- .../apps/settings/partials/current-line.html | 5 +- src/webviews/apps/settings/partials/heatmap.html | 4 +- src/webviews/apps/settings/partials/hovers.html | 17 +- src/webviews/apps/settings/partials/modes.html | 4 +- .../apps/settings/partials/rebase-editor.html | 1 + .../apps/settings/partials/status-bar.html | 6 +- .../apps/settings/partials/views.branches.html | 6 + .../apps/settings/partials/views.commits.html | 20 ++ .../apps/settings/partials/views.contributors.html | 2 +- .../apps/settings/partials/views.file-history.html | 3 +- .../apps/settings/partials/views.line-history.html | 3 +- .../apps/settings/partials/views.remotes.html | 3 + .../apps/settings/partials/views.repositories.html | 2 +- .../settings/partials/views.searchAndCompare.html | 2 +- .../apps/settings/partials/views.stashes.html | 2 + .../apps/settings/partials/views.tags.html | 2 + .../apps/settings/partials/views.worktrees.html | 6 + src/webviews/apps/settings/settings.html | 302 ++++++++++----------- src/webviews/apps/welcome/welcome.html | 32 ++- webpack.config.js | 18 +- 26 files changed, 297 insertions(+), 199 deletions(-) diff --git a/src/webviews/apps/home/home.html b/src/webviews/apps/home/home.html index c75d829..bf5ed1e 100644 --- a/src/webviews/apps/home/home.html +++ b/src/webviews/apps/home/home.html @@ -2,12 +2,6 @@ - @@ -16,8 +10,13 @@
- #{endOfBody} + diff --git a/src/webviews/apps/welcome/welcome.html b/src/webviews/apps/welcome/welcome.html index d1e765d..6a7f3a1 100644 --- a/src/webviews/apps/welcome/welcome.html +++ b/src/webviews/apps/welcome/welcome.html @@ -2,12 +2,6 @@ - @@ -89,21 +83,24 @@
- +
@@ -128,53 +125,62 @@
- +
@@ -199,16 +205,18 @@
- +
@@ -394,5 +402,11 @@ #{endOfBody} + diff --git a/webpack.config.js b/webpack.config.js index 55758cb..19107f3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -280,17 +280,6 @@ function getWebviewsConfig(mode, env) { ), to: path.posix.join(__dirname.replace(/\\/g, '/'), 'dist', 'webviews'), }, - { - from: path.posix.join( - __dirname.replace(/\\/g, '/'), - 'node_modules', - '@vscode', - 'webview-ui-toolkit', - 'dist', - 'toolkit.min.js', - ), - to: path.posix.join(__dirname.replace(/\\/g, '/'), 'dist', 'webviews'), - }, ], }), ]; @@ -522,6 +511,7 @@ function getHtmlPlugin(name, premium, mode, env) { chunks: [name], filename: path.join(__dirname, 'dist', 'webviews', `${name}.html`), inject: true, + scriptLoading: 'module', inlineSource: mode === 'production' ? '.css$' : undefined, minify: mode === 'production' @@ -577,10 +567,10 @@ class InlineChunkHtmlPlugin { compiler.hooks.compilation.tap('InlineChunkHtmlPlugin', compilation => { const getInlinedTagFn = tag => this.getInlinedTag(publicPath, compilation.assets, tag); - + const sortFn = (a, b) => (a.tagName === 'script' ? 1 : -1) - (b.tagName === 'script' ? 1 : -1); this.htmlPlugin.getHooks(compilation).alterAssetTagGroups.tap('InlineChunkHtmlPlugin', assets => { - assets.headTags = assets.headTags.map(getInlinedTagFn); - assets.bodyTags = assets.bodyTags.map(getInlinedTagFn); + assets.headTags = assets.headTags.map(getInlinedTagFn).sort(sortFn); + assets.bodyTags = assets.bodyTags.map(getInlinedTagFn).sort(sortFn); }); }); }