@rpcbase/vite 0.53.0 → 0.55.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.
Files changed (2) hide show
  1. package/index.js +67 -10
  2. package/package.json +3 -1
package/index.js CHANGED
@@ -10,12 +10,19 @@ import {
10
10
  import { viteSingleFile } from "vite-plugin-singlefile"
11
11
  import react from "@vitejs/plugin-react-swc"
12
12
  import { createHtmlPlugin } from "vite-plugin-html"
13
+ import { glob } from "glob"
13
14
 
14
15
 
15
- const ALLOWED_DEV_ENV = ["NODE_ENV", "APP_NAME"]
16
+ // const isCI = process.env.CI === "true"
16
17
 
17
18
  const isProduction = process.env.NODE_ENV === "production"
18
- // const isCI = process.env.CI === "true"
19
+
20
+ const ALLOWED_DEV_ENV = ["NODE_ENV", "APP_NAME"]
21
+ // workaround vite.ssrLoadModule not setting ssrBuild properly
22
+ const ALLOWED_ENV_PREFIXES = [
23
+ "RB_PUBLIC_",
24
+ ...(isProduction ? [] : ALLOWED_DEV_ENV),
25
+ ]
19
26
 
20
27
  // https://github.com/vbenjs/vite-plugin-html?tab=readme-ov-file#minifyoptions
21
28
  const htmlMinifyOptions = {
@@ -67,13 +74,7 @@ export {resolveAliases}
67
74
 
68
75
  // https://vite.dev/config/
69
76
  const getBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
70
- // workaround vite.ssrLoadModule not setting ssrBuild properly
71
- const allowedEnvPrefixes = [
72
- "RB_PUBLIC_",
73
- ...(isProduction ? [] : ALLOWED_DEV_ENV),
74
- ]
75
-
76
- const env = loadEnv(mode, process.cwd(), allowedEnvPrefixes)
77
+ const env = loadEnv(mode, process.cwd(), ALLOWED_ENV_PREFIXES)
77
78
 
78
79
  return {
79
80
  clearScreen: false,
@@ -93,7 +94,7 @@ const getBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
93
94
  ...env,
94
95
  },
95
96
  },
96
- envPrefix: allowedEnvPrefixes,
97
+ envPrefix: ALLOWED_ENV_PREFIXES,
97
98
  publicDir: path.join(process.cwd(), "./src/client/public"),
98
99
  build: {
99
100
  sourcemap: isProduction ? "hidden" : false,
@@ -160,6 +161,62 @@ export const extendConfig = (userConfig) => {
160
161
  })
161
162
  }
162
163
 
164
+ const getSpecBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
165
+ const env = loadEnv(mode, process.cwd(), ALLOWED_ENV_PREFIXES)
166
+
167
+ const input = glob
168
+ .sync("spec/**/*.spec.ts")
169
+ .reduce((inputs, file) => {
170
+ const relativePath = path.relative("spec", file)
171
+ const outputName = relativePath.replace(/\.ts$/, "")
172
+ inputs[outputName] = file
173
+ return inputs
174
+ }, {})
175
+
176
+ return {
177
+ clearScreen: false,
178
+ define: {
179
+ __vite_env__: {
180
+ ...env,
181
+ },
182
+ },
183
+ envPrefix: ALLOWED_ENV_PREFIXES,
184
+ build: {
185
+ outDir: "./build/spec/",
186
+ ssr: true,
187
+ rollupOptions: {
188
+ input,
189
+ },
190
+ commonjsOptions: { transformMixedEsModules: true },
191
+ },
192
+ resolve: {
193
+ alias: {
194
+ ...resolveAliases,
195
+ },
196
+ preserveSymlinks: true,
197
+ },
198
+ ssr: {
199
+ external: ["mongoose"],
200
+ noExternal: ["@rpcbase/*"],
201
+ },
202
+ }
203
+ }
204
+
205
+ export const extendSpecConfig = (userConfig) => {
206
+ return defineConfig(({ command, mode, isSsrBuild, isPreview }) => {
207
+ let config
208
+ if (typeof userConfig === "function") {
209
+ config = userConfig({ command, mode, isSsrBuild, isPreview })
210
+ } else {
211
+ config = userConfig
212
+ }
213
+ const baseConfig = getSpecBaseConfig({ command, mode, isSsrBuild, isPreview })
214
+
215
+ return mergeConfig(baseConfig, config)
216
+ })
217
+ }
218
+
219
+
163
220
  export const createServer = viteCreateServer
164
221
  // export const createServer = async (config /* : Record<string, any>*/) => {
165
222
  // const env = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/vite",
3
- "version": "0.53.0",
3
+ "version": "0.55.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "scripts": {
@@ -31,7 +31,9 @@
31
31
  "@vitejs/plugin-react-swc": "3.10.2",
32
32
  "clsx": "2.1.1",
33
33
  "framer-motion": "12.19.2",
34
+ "glob": "11.0.3",
34
35
  "libphonenumber-js": "1.12.9",
36
+ "lucide-react": "0.545.0",
35
37
  "maplibre-gl": "5.6.0",
36
38
  "nocache": "4.0.0",
37
39
  "openai": "5.8.2",