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.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
writeFile,
|
||||
} from "fs-extra";
|
||||
import { resolve, join } from "path";
|
||||
import { isDevBuild } from "./dev";
|
||||
|
||||
export interface DeployedPackage {
|
||||
distPath: string;
|
||||
@@ -53,8 +54,6 @@ export async function deployPackage(
|
||||
await readFile(packageJsonPath, "utf8"),
|
||||
);
|
||||
|
||||
// Default to development build; use flag --release to indicate release build.
|
||||
const isDevBuild = !process.argv.includes("--release");
|
||||
const distDir = join(__dirname, "../../../dist");
|
||||
await mkdirs(distDir);
|
||||
|
||||
|
||||
2
extensions/ql-vscode/gulpfile.ts/dev.ts
Normal file
2
extensions/ql-vscode/gulpfile.ts/dev.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
// Default to development build; use flag --release to indicate release build.
|
||||
export const isDevBuild = !process.argv.includes("--release");
|
||||
@@ -1,9 +1,10 @@
|
||||
import { resolve } from "path";
|
||||
import * as webpack from "webpack";
|
||||
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
||||
import { isDevBuild } from "./dev";
|
||||
|
||||
export const config: webpack.Configuration = {
|
||||
mode: "development",
|
||||
mode: isDevBuild ? "development" : "production",
|
||||
entry: {
|
||||
webview: "./src/view/webview.tsx",
|
||||
},
|
||||
@@ -11,7 +12,7 @@ export const config: webpack.Configuration = {
|
||||
path: resolve(__dirname, "..", "out"),
|
||||
filename: "[name].js",
|
||||
},
|
||||
devtool: "inline-source-map",
|
||||
devtool: isDevBuild ? "inline-source-map" : "source-map",
|
||||
resolve: {
|
||||
extensions: [".js", ".ts", ".tsx", ".json"],
|
||||
fallback: {
|
||||
|
||||
Reference in New Issue
Block a user