Skip to content

Commit f6f8b68

Browse files
committed
Use Webpack in production mode for releases
This will set the `mode` of Webpack to `production` for release builds. It will also stop inlining the sourcemap and instead produce a separate file which is excluded by `.vscodeignore`. In terms of the bundled extension, this will add 1 file (`out/webview.js.LICENSE.txt`). It decreases the size of the VSIX file from 4.28MB to 1.77MB.
1 parent f82fde3 commit f6f8b68

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

extensions/ql-vscode/gulpfile.ts/deploy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
writeFile,
99
} from "fs-extra";
1010
import { resolve, join } from "path";
11+
import { isDevBuild } from "./dev";
1112

1213
export interface DeployedPackage {
1314
distPath: string;
@@ -53,8 +54,6 @@ export async function deployPackage(
5354
await readFile(packageJsonPath, "utf8"),
5455
);
5556

56-
// Default to development build; use flag --release to indicate release build.
57-
const isDevBuild = !process.argv.includes("--release");
5857
const distDir = join(__dirname, "../../../dist");
5958
await mkdirs(distDir);
6059

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Default to development build; use flag --release to indicate release build.
2+
export const isDevBuild = !process.argv.includes("--release");

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { resolve } from "path";
22
import * as webpack from "webpack";
33
import MiniCssExtractPlugin from "mini-css-extract-plugin";
4+
import { isDevBuild } from "./dev";
45

56
export const config: webpack.Configuration = {
6-
mode: "development",
7+
mode: isDevBuild ? "development" : "production",
78
entry: {
89
webview: "./src/view/webview.tsx",
910
},
1011
output: {
1112
path: resolve(__dirname, "..", "out"),
1213
filename: "[name].js",
1314
},
14-
devtool: "inline-source-map",
15+
devtool: isDevBuild ? "inline-source-map" : "source-map",
1516
resolve: {
1617
extensions: [".js", ".ts", ".tsx", ".json"],
1718
fallback: {

0 commit comments

Comments
 (0)