@rpcbase/vite 0.4.0 → 0.6.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 +97 -73
- package/package.json +9 -9
package/index.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import path from "path"
|
|
2
2
|
import nocache from "nocache"
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createServer as viteCreateServer,
|
|
5
|
+
defineConfig,
|
|
6
|
+
mergeConfig,
|
|
7
|
+
loadEnv,
|
|
8
|
+
} from "vite"
|
|
4
9
|
|
|
5
10
|
import react from "@vitejs/plugin-react-swc"
|
|
6
11
|
// @ts-ignore
|
|
7
12
|
import tailwindcss from "@tailwindcss/vite"
|
|
8
13
|
|
|
9
|
-
const
|
|
14
|
+
const ALLOWED_DEV_ENV = ["NODE_ENV", "APP_NAME", "DB_NAME"]
|
|
10
15
|
|
|
11
|
-
const
|
|
12
|
-
"NODE_ENV",
|
|
13
|
-
"APP_NAME",
|
|
14
|
-
"DB_NAME"
|
|
15
|
-
]
|
|
16
|
+
const isProduction = process.env.NODE_ENV === "production"
|
|
16
17
|
|
|
17
|
-
// workaround vite.ssrLoadModule not setting ssrBuild properly
|
|
18
|
-
const allowedEnvPrefixes = ["RB_PUBLIC_", ...(isProduction ? [] : ALLOWED_DEV_ENV)]
|
|
19
|
-
const env = loadEnv("development", process.cwd(), allowedEnvPrefixes)
|
|
20
18
|
|
|
21
19
|
export const resolveAliases = {
|
|
22
20
|
"@/api": path.resolve(process.cwd(), "./src/api/"),
|
|
@@ -25,77 +23,104 @@ export const resolveAliases = {
|
|
|
25
23
|
"@/types": path.resolve(process.cwd(), "./src/types/"),
|
|
26
24
|
"@": path.resolve(process.cwd(), "./src/client/"),
|
|
27
25
|
//
|
|
28
|
-
"react-hook-form": path.resolve(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
"react-hook-form": path.resolve(
|
|
27
|
+
process.cwd(),
|
|
28
|
+
"./node_modules/react-hook-form",
|
|
29
|
+
),
|
|
30
|
+
"@hookform/resolvers": path.resolve(
|
|
31
|
+
process.cwd(),
|
|
32
|
+
"./node_modules/@hookform/resolvers",
|
|
33
|
+
),
|
|
34
|
+
cookie: path.resolve(process.cwd(), "./node_modules/cookie"),
|
|
35
|
+
"set-cookie-parser": path.resolve(
|
|
36
|
+
process.cwd(),
|
|
37
|
+
"./node_modules/set-cookie-parser",
|
|
38
|
+
),
|
|
32
39
|
// "react-dom": path.resolve(import.meta.dirname, "./node_modules/react-dom"),
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
|
|
36
42
|
// https://vite.dev/config/
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const getBaseConfig = ({ command, mode, isSsrBuild, isPreview }) => {
|
|
44
|
+
|
|
45
|
+
// workaround vite.ssrLoadModule not setting ssrBuild properly
|
|
46
|
+
const allowedEnvPrefixes = [
|
|
47
|
+
"RB_PUBLIC_",
|
|
48
|
+
...(isProduction ? [] : ALLOWED_DEV_ENV),
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
const env = loadEnv(mode, process.cwd(), allowedEnvPrefixes)
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
clearScreen: false,
|
|
55
|
+
plugins: [react(), tailwindcss()],
|
|
56
|
+
define: {
|
|
57
|
+
"__vite_env__": {
|
|
58
|
+
...env,
|
|
59
|
+
},
|
|
46
60
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
publicDir: path.join(process.cwd(), "./src/client/public"),
|
|
62
|
+
build: {
|
|
63
|
+
outDir: "./build/dist/",
|
|
64
|
+
rollupOptions: {
|
|
65
|
+
input: {
|
|
66
|
+
app: "./src/client/index.html",
|
|
67
|
+
},
|
|
54
68
|
},
|
|
69
|
+
commonjsOptions: { transformMixedEsModules: true },
|
|
55
70
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
server: {
|
|
72
|
+
allowedHosts: true,
|
|
73
|
+
headers: {
|
|
74
|
+
"Cache-Control": "no-store",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
resolve: {
|
|
78
|
+
alias: {
|
|
79
|
+
...resolveAliases,
|
|
80
|
+
},
|
|
81
|
+
preserveSymlinks: true,
|
|
62
82
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
83
|
+
ssr: {
|
|
84
|
+
external: [
|
|
85
|
+
// "react", "react-dom",
|
|
86
|
+
"cookie",
|
|
87
|
+
],
|
|
88
|
+
// noExternal: ["react-hook-form"],
|
|
67
89
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
optimizeDeps: {
|
|
91
|
+
include: [
|
|
92
|
+
// "react", "react-dom", "react-dom/server"
|
|
93
|
+
// "cookie"
|
|
94
|
+
],
|
|
95
|
+
exclude: [
|
|
96
|
+
"@rpcbase/auth",
|
|
97
|
+
"@rpcbase/form",
|
|
98
|
+
"@rpcbase/router",
|
|
99
|
+
"react-router",
|
|
100
|
+
"@radix-ui/*",
|
|
101
|
+
// "react", "react-dom/server",
|
|
102
|
+
// "react-hook-form",
|
|
103
|
+
// "react-dom"
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const extendConfig = (userConfig) => {
|
|
110
|
+
return defineConfig(({ command, mode, isSsrBuild, isPreview }) => {
|
|
111
|
+
let config
|
|
112
|
+
if (typeof userConfig === "function") {
|
|
113
|
+
config = userConfig({ command, mode, isSsrBuild, isPreview })
|
|
114
|
+
} else {
|
|
115
|
+
config = userConfig
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const baseConfig = getBaseConfig({ command, mode, isSsrBuild, isPreview })
|
|
119
|
+
return mergeConfig(baseConfig, config)
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const createServer = async (config /* : Record<string, any>*/) => {
|
|
99
124
|
const extendedConfig = extendConfig(config)
|
|
100
125
|
delete extendedConfig.plugins
|
|
101
126
|
|
|
@@ -104,7 +129,6 @@ export const createServer = async(config/* : Record<string, any>*/) => {
|
|
|
104
129
|
return viteServer
|
|
105
130
|
}
|
|
106
131
|
|
|
107
|
-
|
|
108
132
|
export const disableAppCache = (app) => {
|
|
109
133
|
app.set("etag", false)
|
|
110
134
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@swc/core": "1.
|
|
28
|
-
"@tailwindcss/vite": "4.0.
|
|
29
|
-
"@vitejs/plugin-react-swc": "3.
|
|
27
|
+
"@swc/core": "1.11.7",
|
|
28
|
+
"@tailwindcss/vite": "4.0.12",
|
|
29
|
+
"@vitejs/plugin-react-swc": "3.8.0",
|
|
30
30
|
"clsx": "2.1.1",
|
|
31
|
-
"libphonenumber-js": "1.
|
|
32
|
-
"mongoose": "8.
|
|
31
|
+
"libphonenumber-js": "1.12.5",
|
|
32
|
+
"mongoose": "8.12.1",
|
|
33
33
|
"nocache": "4.0.0",
|
|
34
34
|
"react": "19.0.0",
|
|
35
35
|
"react-dom": "19.0.0",
|
|
36
|
-
"react-router": "7.
|
|
36
|
+
"react-router": "7.3.0",
|
|
37
37
|
"swc-plugin-add-display-name": "0.5.0",
|
|
38
38
|
"tailwindcss": "4.0.3",
|
|
39
39
|
"validator": "13.12.0",
|
|
40
|
-
"vite": "6.1
|
|
41
|
-
"zod": "3.24.
|
|
40
|
+
"vite": "6.2.1",
|
|
41
|
+
"zod": "3.24.2"
|
|
42
42
|
}
|
|
43
43
|
}
|