Skip to content

Commit a0017e9

Browse files
committed
chore: fix build error
1 parent a3dbc2d commit a0017e9

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

webpack/webpack.common.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ const config = {
351351
use: [
352352
{
353353
loader: 'babel-loader',
354+
options: {
355+
presets: [['@babel/preset-env', { modules: false }], '@babel/preset-react'],
356+
plugins: ['@babel/plugin-transform-object-rest-spread', '@babel/plugin-transform-runtime'],
357+
},
354358
},
355359
{
356360
loader: '@svgr/webpack',

webpack/webpack.prod.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const prodWebpackConfig = merge(common, {
4949
...(hasOptimizedVideo ? { '@assets/video': optimizedVideoDir } : {}),
5050
},
5151
}
52-
: undefined,
52+
: {},
5353
// 使用文件缓存
5454
cache: { type: 'filesystem', buildDependencies: { config: [__filename] } },
5555
// 生产调试开关:设置环境变量 DEBUG_PROD=1 可在 production 构建中输出 source-map 并关闭压缩,便于定位仅在构建后出现的问题。
@@ -103,29 +103,34 @@ const prodWebpackConfig = merge(common, {
103103
process.env.DEBUG_PROD === '1'
104104
? []
105105
: [
106-
new CssMinimizerPlugin(),
106+
new CssMinimizerPlugin({
107+
minify: CssMinimizerPlugin.cssnanoMinify,
108+
}),
107109
new EsbuildPlugin({
108110
target: 'es2018',
109111
// 保留对象展开操作符,避免生成有问题的辅助函数
110112
keepNames: true,
111113
}),
112-
new HtmlMinimizerPlugin(),
113-
new ImageMinimizerPlugin({
114-
loader: false,
115-
test: /\.(png|jpe?g|gif|webp|avif)$/i,
116-
minimizer: {
117-
implementation: ImageMinimizerPlugin.sharpMinify,
118-
options: {
119-
encodeOptions: {
120-
// Safe defaults; tune per your quality/size preference.
121-
jpeg: { quality: 78, mozjpeg: true },
122-
png: { compressionLevel: 9, palette: true },
123-
webp: { quality: 80 },
124-
avif: { quality: 50 },
125-
},
126-
},
127-
},
114+
new HtmlMinimizerPlugin({
115+
minify: HtmlMinimizerPlugin.htmlMinifierTerserMinify,
128116
}),
117+
// Temporarily disabled ImageMinimizerPlugin
118+
// new ImageMinimizerPlugin({
119+
// loader: false,
120+
// test: /\.(png|jpe?g|gif|webp|avif)$/i,
121+
// minimizer: {
122+
// implementation: ImageMinimizerPlugin.sharpMinify,
123+
// options: {
124+
// encodeOptions: {
125+
// // Safe defaults; tune per your quality/size preference.
126+
// jpeg: { quality: 78, mozjpeg: true },
127+
// png: { compressionLevel: 9, palette: true },
128+
// webp: { quality: 80 },
129+
// avif: { quality: 50 },
130+
// },
131+
// },
132+
// },
133+
// }),
129134
],
130135
splitChunks: {
131136
chunks: 'all',

0 commit comments

Comments
 (0)