Skip to content

Commit

Permalink
chore: 移除 vite-plugin-replace 插件,可用 define['process.env.NODE_ENV'] 代替
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Jun 17, 2024
1 parent 21de87f commit ce00f75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
"tsc-alias": "^1.8.7",
"typescript": "^5.4.5",
"vite": "^5.2.13",
"vite-plugin-replace": "^0.1.1",
"yalc": "1.0.0-pre.53"
},
"browserslist": {
Expand Down
16 changes: 10 additions & 6 deletions packages/react-ui/vite.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { replaceCodePlugin } from 'vite-plugin-replace';
// import { replaceCodePlugin } from 'vite-plugin-replace';
import { visualizer } from 'rollup-plugin-visualizer';
import type { RequiredPart } from '@tool-pack/types';
import type { UserConfig, Plugin } from 'vite';
Expand Down Expand Up @@ -37,11 +37,11 @@ export function getCommonViteConfig(
// react({
// jsxRuntime: 'classic',
// }),
replaceCodePlugin({
replacements: [
{ to: JSON.stringify('production'), from: 'process.env.NODE_ENV' },
],
}),
// replaceCodePlugin({
// replacements: [
// { to: JSON.stringify('production'), from: 'process.env.NODE_ENV' },
// ],
// }),
{
...(visualizer({ filename: 'temp/analyze.html' }) as Plugin),
apply(_, { mode }) {
Expand All @@ -64,6 +64,10 @@ export function getCommonViteConfig(
esbuild: {
tsconfigRaw: { compilerOptions: { jsx: 'react' } },
},
// 环境变量配置
define: {
'process.env.NODE_ENV': "'production'",
},
resolve: {
alias: getAlias(),
},
Expand Down
12 changes: 0 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ce00f75

Please sign in to comment.