@rpcbase/vite 0.76.0 → 0.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +21 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -117,9 +117,27 @@ const rbPackagesNeedingEnvPolyfill = [
|
|
|
117
117
|
"@rpcbase/router",
|
|
118
118
|
]
|
|
119
119
|
|
|
120
|
+
const createRuntimeEnv = ({ env, command, mode, isSsrBuild }) => {
|
|
121
|
+
const isDevCommand = command === "serve"
|
|
122
|
+
|
|
123
|
+
const mergedEnv = {
|
|
124
|
+
...env,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
...mergedEnv,
|
|
129
|
+
BASE_URL: mergedEnv.BASE_URL ?? "/",
|
|
130
|
+
MODE: mode,
|
|
131
|
+
DEV: isDevCommand,
|
|
132
|
+
PROD: !isDevCommand,
|
|
133
|
+
SSR: Boolean(isSsrBuild),
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
120
137
|
// https://vite.dev/config/
|
|
121
138
|
const getBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
|
|
122
139
|
const env = loadEnv(mode, process.cwd(), ALLOWED_ENV_PREFIXES)
|
|
140
|
+
const runtimeEnv = createRuntimeEnv({ env, command, mode, isSsrBuild })
|
|
123
141
|
|
|
124
142
|
return {
|
|
125
143
|
clearScreen: false,
|
|
@@ -138,9 +156,7 @@ const getBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
|
|
|
138
156
|
isProduction && posthogSourcemapsPlugin({}),
|
|
139
157
|
].filter(Boolean),
|
|
140
158
|
define: {
|
|
141
|
-
|
|
142
|
-
...env,
|
|
143
|
-
}),
|
|
159
|
+
__vite_env__: runtimeEnv,
|
|
144
160
|
},
|
|
145
161
|
envPrefix: ALLOWED_ENV_PREFIXES,
|
|
146
162
|
publicDir: path.join(process.cwd(), "./src/client/public"),
|
|
@@ -224,6 +240,7 @@ export const extendConfig = (userConfig) => {
|
|
|
224
240
|
|
|
225
241
|
const getSpecBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
|
|
226
242
|
const env = loadEnv(mode, process.cwd(), ALLOWED_ENV_PREFIXES)
|
|
243
|
+
const runtimeEnv = createRuntimeEnv({ env, command, mode, isSsrBuild })
|
|
227
244
|
|
|
228
245
|
const input = glob
|
|
229
246
|
.sync("spec/**/*.spec.ts")
|
|
@@ -237,9 +254,7 @@ const getSpecBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
|
|
|
237
254
|
return {
|
|
238
255
|
clearScreen: false,
|
|
239
256
|
define: {
|
|
240
|
-
__vite_env__:
|
|
241
|
-
...env,
|
|
242
|
-
},
|
|
257
|
+
__vite_env__: runtimeEnv,
|
|
243
258
|
},
|
|
244
259
|
envPrefix: ALLOWED_ENV_PREFIXES,
|
|
245
260
|
build: {
|