From 748d86418dc3bc84af97f81b881195e9f1f0dafb Mon Sep 17 00:00:00 2001 From: Lim Jet <57783762+daoauth@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:51:46 +0900 Subject: [PATCH] update optimization --- package-lock.json | 1 + package.json | 1 + webpack.config.js | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a1c577f..2ac90a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "path-browserify": "^1.0.1", "prettier": "^3.3.3", "process": "^0.11.10", + "terser-webpack-plugin": "^5.3.10", "ts-loader": "^9.5.1", "typescript": "^5.4.5", "webpack": "^5.92.1", diff --git a/package.json b/package.json index 01ecb06..c655101 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "path-browserify": "^1.0.1", "prettier": "^3.3.3", "process": "^0.11.10", + "terser-webpack-plugin": "^5.3.10", "ts-loader": "^9.5.1", "typescript": "^5.4.5", "webpack": "^5.92.1", diff --git a/webpack.config.js b/webpack.config.js index d5667cb..7ee4096 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,13 +9,18 @@ const path = require('path'); const webpack = require('webpack'); +const TerserPlugin = require("terser-webpack-plugin"); //@ts-check /** @typedef {import('webpack').Configuration} WebpackConfig **/ /** @type WebpackConfig */ const webExtensionConfig = { - mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + mode: 'production', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, target: 'webworker', // extensions run in a webworker context entry: './src/extension.ts', // source of the web extension main file output: { @@ -70,7 +75,11 @@ const webExtensionConfig = { /** @type WebpackConfig */ const nodeExtensionConfig = { - mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + mode: 'production', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/ entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/