-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from webpack to esbuild for bundling webviews
This PR uses esbuild instead of webpack to bundle the webviews. This dramatically reduces the time it takes to bundle the webviews, from >50 seconds to <1 second. This PR also modifies the npm scripts and VS Code launch configurations to always recompile the webviews before launching. I also set up eslint to be run before launching the extension. If the extension seems slower to launch in debug mode, this is why. Closes #2875 Signed-off-by: David Thompson <davthomp@redhat.com>
- Loading branch information
Showing
49 changed files
with
1,092 additions
and
3,681 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*----------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*-----------------------------------------------------------------------------------------------*/ | ||
|
||
import * as esbuild from 'esbuild'; | ||
import { sassPlugin } from 'esbuild-sass-plugin'; | ||
import * as fs from 'fs/promises'; | ||
|
||
const webviews = [ | ||
'cluster', | ||
'create-service', | ||
'describe', | ||
'devfile-registry', | ||
'git-import', | ||
'helm-chart', | ||
'log', | ||
'welcome', | ||
]; | ||
|
||
function kebabToCamel(text) { | ||
return text.replace(/-./g, searchResult => searchResult.substring(1).toUpperCase()); | ||
} | ||
|
||
await Promise.all([ | ||
...webviews.map(webview => | ||
esbuild.build({ | ||
entryPoints: [ | ||
`./src/webview/${webview}/app/index.tsx`, | ||
], | ||
bundle: true, | ||
outfile: `./out/${kebabToCamel(webview)}Viewer/index.js`, | ||
platform: 'browser', | ||
target: 'chrome108', | ||
sourcemap: true, | ||
loader: { | ||
'.png': 'file', | ||
'.svg': 'file', | ||
}, | ||
plugins: [ | ||
sassPlugin(), | ||
] | ||
}) | ||
), | ||
...webviews.map(webview => | ||
fs.cp(`./src/webview/${webview}/app/index.html`, `./out/${kebabToCamel(webview)}Viewer/index.html`) | ||
), | ||
]); |
Oops, something went wrong.