使用 esbuid-loader 提高前端代码的编译速度 (#7525)

* 用esbuild-loader加快打包速度

* fix: dev 模式下,esbuild 不混淆源码

* fix: 变量名混淆、删除不用的包
This commit is contained in:
yb6b 2023-03-02 08:48:29 +08:00 committed by GitHub
parent 9574085b03
commit b649a70e8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 306 additions and 71 deletions

View file

@ -5,7 +5,7 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
// const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const TerserPlugin = require("terser-webpack-plugin");
const { EsbuildPlugin } = require("esbuild-loader");
module.exports = (env, argv) => {
return {
@ -23,14 +23,7 @@ module.exports = (env, argv) => {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
format: {
comments: false,
},
},
extractComments: false,
}),
new EsbuildPlugin(),
],
},
resolve: {
@ -55,7 +48,11 @@ module.exports = (env, argv) => {
include: [path.resolve(__dirname, "src")],
use: [
{
loader: "ts-loader",
loader: "esbuild-loader",
options: {
minify: false,
keepNames: true,
},
},
{
loader: "ifdef-loader",