Skip to content

Commit ce00f75

Browse files
committed
chore: 移除 vite-plugin-replace 插件,可用 define['process.env.NODE_ENV'] 代替
1 parent 21de87f commit ce00f75

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
"tsc-alias": "^1.8.7",
117117
"typescript": "^5.4.5",
118118
"vite": "^5.2.13",
119-
"vite-plugin-replace": "^0.1.1",
120119
"yalc": "1.0.0-pre.53"
121120
},
122121
"browserslist": {

packages/react-ui/vite.utils.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { replaceCodePlugin } from 'vite-plugin-replace';
1+
// import { replaceCodePlugin } from 'vite-plugin-replace';
22
import { visualizer } from 'rollup-plugin-visualizer';
33
import type { RequiredPart } from '@tool-pack/types';
44
import type { UserConfig, Plugin } from 'vite';
@@ -37,11 +37,11 @@ export function getCommonViteConfig(
3737
// react({
3838
// jsxRuntime: 'classic',
3939
// }),
40-
replaceCodePlugin({
41-
replacements: [
42-
{ to: JSON.stringify('production'), from: 'process.env.NODE_ENV' },
43-
],
44-
}),
40+
// replaceCodePlugin({
41+
// replacements: [
42+
// { to: JSON.stringify('production'), from: 'process.env.NODE_ENV' },
43+
// ],
44+
// }),
4545
{
4646
...(visualizer({ filename: 'temp/analyze.html' }) as Plugin),
4747
apply(_, { mode }) {
@@ -64,6 +64,10 @@ export function getCommonViteConfig(
6464
esbuild: {
6565
tsconfigRaw: { compilerOptions: { jsx: 'react' } },
6666
},
67+
// 环境变量配置
68+
define: {
69+
'process.env.NODE_ENV': "'production'",
70+
},
6771
resolve: {
6872
alias: getAlias(),
6973
},

pnpm-lock.yaml

-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)