Skip to content

Commit aea1582

Browse files
committed
build: webpack build
1 parent 418859c commit aea1582

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

src/pages/chatgpt/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ PRD文档内容:
16081608
data-color-mode={previewTheme}
16091609
skipHtml={false}
16101610
remarkPlugins={[remarkMath]}
1611-
rehypePlugins={[rehypeKatex]}
1611+
rehypePlugins={[[rehypeKatex, { strict: 'ignore' }]]}
16121612
components={CustomComponents}
16131613
/>
16141614
</div>
@@ -1751,7 +1751,7 @@ PRD文档内容:
17511751
data-color-mode={previewTheme}
17521752
skipHtml={false}
17531753
remarkPlugins={[remarkMath]}
1754-
rehypePlugins={[rehypeKatex]}
1754+
rehypePlugins={[[rehypeKatex, { strict: 'ignore' }]]}
17551755
components={CustomComponents}
17561756
/>
17571757

webpack/webpack.common.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path'
1+
import path, { dirname } from 'path'
22
import HtmlWebpackPlugin from 'html-webpack-plugin'
33
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
44
import AntdDayjsWebpackPlugin from 'antd-dayjs-webpack-plugin'
@@ -12,7 +12,6 @@ import ESLintWebpackPlugin from 'eslint-webpack-plugin'
1212
import { codeInspectorPlugin } from 'code-inspector-plugin'
1313
import paths from './paths.js'
1414
import { fileURLToPath } from 'url'
15-
import { dirname } from 'path'
1615

1716
const __filename = fileURLToPath(import.meta.url)
1817
const __dirname = dirname(__filename)

webpack/webpack.prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path'
1+
import path, { dirname } from 'path'
22
import fs from 'fs'
33
import { merge } from 'webpack-merge'
44
import CopyWebpackPlugin from 'copy-webpack-plugin'
@@ -16,7 +16,6 @@ import ImageMinimizerPlugin from 'image-minimizer-webpack-plugin'
1616
import common from './webpack.common.js'
1717
import dotenv from 'dotenv'
1818
import { fileURLToPath } from 'url'
19-
import { dirname } from 'path'
2019

2120
const __filename = fileURLToPath(import.meta.url)
2221
const __dirname = dirname(__filename)
@@ -49,8 +48,9 @@ const prodWebpackConfig = merge(common, {
4948
: undefined,
5049
// 使用文件缓存
5150
cache: { type: 'filesystem', buildDependencies: { config: [__filename] } },
52-
// devtool: 'source-map',
53-
devtool: false,
51+
// 生产调试开关:设置环境变量 DEBUG_PROD=1 可在 production 构建中输出 source-map 并关闭压缩,便于定位仅在构建后出现的问题。
52+
// 默认保持原有生产行为(无 source-map,开启压缩)。
53+
devtool: process.env.DEBUG_PROD === '1' ? 'source-map' : false,
5454
plugins: [
5555
new webpack.ProvidePlugin({
5656
React: 'react',
@@ -91,8 +91,8 @@ const prodWebpackConfig = merge(common, {
9191
}),
9292
],
9393
optimization: {
94-
minimize: true,
95-
minimizer: [
94+
minimize: process.env.DEBUG_PROD !== '1',
95+
minimizer: process.env.DEBUG_PROD === '1' ? [] : [
9696
new CssMinimizerPlugin(),
9797
new EsbuildPlugin({
9898
target: 'es2015',

0 commit comments

Comments
 (0)