diff --git a/packages/vscode-extension/webpack.config.js b/packages/vscode-extension/webpack.config.js index 32767ddac..e5ce6e285 100644 --- a/packages/vscode-extension/webpack.config.js +++ b/packages/vscode-extension/webpack.config.js @@ -52,6 +52,26 @@ const baseConfig = { }, } +/** + * @param {WebpackConfig | (() => Promise)} config + * @param {number} maxBytes + * @returns {(env: any, argv: any) => Promise} + */ +function withBudget(config, maxBytes) { + return async (_env, argv) => { + const resolved = typeof config === 'function' ? await config() : config; + if (argv?.mode !== 'production') return resolved; + return { + ...resolved, + performance: { + hints: 'error', + maxAssetSize: maxBytes, + maxEntrypointSize: maxBytes, + }, + }; + }; +} + /** @type WebpackConfig */ const desktopConfig = { ...baseConfig, @@ -175,4 +195,8 @@ const browserServerConfig = async () => { }; }; -module.exports = [desktopConfig, browserClientConfig, browserServerConfig]; +module.exports = [ + withBudget(desktopConfig, 8_000_000), + withBudget(browserClientConfig, 2_600_000), + withBudget(browserServerConfig, 8_000_000), +];