From ce00f7519036885abd57458a35ddc6c8723f3202 Mon Sep 17 00:00:00 2001 From: dyh_a Date: Mon, 17 Jun 2024 19:10:46 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=20vite-plugin-repla?= =?UTF-8?q?ce=20=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=8F=AF=E7=94=A8=20define['pr?= =?UTF-8?q?ocess.env.NODE=5FENV']=20=E4=BB=A3=E6=9B=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 - packages/react-ui/vite.utils.ts | 16 ++++++++++------ pnpm-lock.yaml | 12 ------------ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index dd19f94..3762940 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/packages/react-ui/vite.utils.ts b/packages/react-ui/vite.utils.ts index 150ff05..e13fec5 100644 --- a/packages/react-ui/vite.utils.ts +++ b/packages/react-ui/vite.utils.ts @@ -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'; @@ -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 }) { @@ -64,6 +64,10 @@ export function getCommonViteConfig( esbuild: { tsconfigRaw: { compilerOptions: { jsx: 'react' } }, }, + // 环境变量配置 + define: { + 'process.env.NODE_ENV': "'production'", + }, resolve: { alias: getAlias(), }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df3300d..337c769 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -201,9 +201,6 @@ importers: vite: specifier: ^5.2.13 version: 5.2.13(@types/node@20.14.2)(less@4.1.3)(lightningcss@1.22.1)(sass@1.77.4)(terser@5.31.1) - vite-plugin-replace: - specifier: ^0.1.1 - version: 0.1.1(vite@5.2.13(@types/node@20.14.2)(less@4.1.3)(lightningcss@1.22.1)(sass@1.77.4)(terser@5.31.1)) yalc: specifier: 1.0.0-pre.53 version: 1.0.0-pre.53 @@ -11768,11 +11765,6 @@ packages: vfile@5.3.7: resolution: {integrity: sha512-r7qlzkgErKjobAmyNIkkSpizsFPYiUPuJb5pNW1RB4JcYVZhs4lIbVqk8XPk033CV/1z8ss5pkax8SuhGpcG8g==} - vite-plugin-replace@0.1.1: - resolution: {integrity: sha512-v+okl3JNt2pf1jDYijw+WPVt6h9FWa/atTi+qnSFBqmKThLTDhlesx0r3bh+oFPmxRJmis5tNx9HtN6lGFoqWg==} - peerDependencies: - vite: ^2 - vite@4.5.2: resolution: {integrity: sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==} engines: {node: ^14.18.0 || >=16.0.0} @@ -26527,10 +26519,6 @@ snapshots: unist-util-stringify-position: 3.0.3 vfile-message: 3.1.4 - vite-plugin-replace@0.1.1(vite@5.2.13(@types/node@20.14.2)(less@4.1.3)(lightningcss@1.22.1)(sass@1.77.4)(terser@5.31.1)): - dependencies: - vite: 5.2.13(@types/node@20.14.2)(less@4.1.3)(lightningcss@1.22.1)(sass@1.77.4)(terser@5.31.1) - vite@4.5.2(@types/node@20.14.2)(less@4.1.3)(lightningcss@1.22.1)(sass@1.77.4)(terser@5.31.1): dependencies: esbuild: 0.18.20