@rpcbase/vite 0.0.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 +112 -0
- package/package.json +42 -0
package/index.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import path from "path"
|
|
2
|
+
import nocache from "nocache"
|
|
3
|
+
import {createServer as viteCreateServer, defineConfig, mergeConfig, loadEnv } from "vite"
|
|
4
|
+
|
|
5
|
+
import react from "@vitejs/plugin-react-swc"
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import tailwindcss from "@tailwindcss/vite"
|
|
8
|
+
|
|
9
|
+
const isProduction = process.env.NODE_ENV === "production"
|
|
10
|
+
|
|
11
|
+
const ALLOWED_DEV_ENV = [
|
|
12
|
+
"NODE_ENV",
|
|
13
|
+
"APP_NAME",
|
|
14
|
+
"DB_NAME"
|
|
15
|
+
]
|
|
16
|
+
|
|
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
|
+
|
|
21
|
+
export const resolveAliases = {
|
|
22
|
+
"@/api": path.resolve(process.cwd(), "./src/api/"),
|
|
23
|
+
"@/models": path.resolve(process.cwd(), "./src/models/"),
|
|
24
|
+
"@/shared": path.resolve(process.cwd(), "./src/shared/"),
|
|
25
|
+
"@/types": path.resolve(process.cwd(), "./src/types/"),
|
|
26
|
+
"@": path.resolve(process.cwd(), "./src/client/"),
|
|
27
|
+
//
|
|
28
|
+
"react-hook-form": path.resolve(process.cwd(), "./node_modules/react-hook-form"),
|
|
29
|
+
"@hookform/resolvers": path.resolve(process.cwd(), "./node_modules/@hookform/resolvers"),
|
|
30
|
+
"cookie": path.resolve(process.cwd(), "./node_modules/cookie"),
|
|
31
|
+
"set-cookie-parser": path.resolve(process.cwd(), "./node_modules/set-cookie-parser"),
|
|
32
|
+
// "react-dom": path.resolve(import.meta.dirname, "./node_modules/react-dom"),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// https://vite.dev/config/
|
|
37
|
+
const baseConfig = defineConfig({
|
|
38
|
+
clearScreen: false,
|
|
39
|
+
plugins: [
|
|
40
|
+
react(),
|
|
41
|
+
tailwindcss(),
|
|
42
|
+
],
|
|
43
|
+
define: {
|
|
44
|
+
"process.env": {
|
|
45
|
+
...env,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
publicDir: path.join(process.cwd(), "./src/client/public"),
|
|
49
|
+
build: {
|
|
50
|
+
outDir: "./build/dist/",
|
|
51
|
+
rollupOptions: {
|
|
52
|
+
input: {
|
|
53
|
+
app: "./src/client/index.html",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
commonjsOptions: {transformMixedEsModules: true}
|
|
57
|
+
},
|
|
58
|
+
server: {
|
|
59
|
+
allowedHosts: true,
|
|
60
|
+
headers: {
|
|
61
|
+
"Cache-Control": "no-store",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
resolve: {
|
|
65
|
+
alias: {
|
|
66
|
+
...resolveAliases,
|
|
67
|
+
},
|
|
68
|
+
preserveSymlinks: true,
|
|
69
|
+
},
|
|
70
|
+
ssr: {
|
|
71
|
+
external: [
|
|
72
|
+
// "react", "react-dom",
|
|
73
|
+
"cookie"
|
|
74
|
+
],
|
|
75
|
+
// noExternal: ["react-hook-form"],
|
|
76
|
+
},
|
|
77
|
+
optimizeDeps: {
|
|
78
|
+
include: [
|
|
79
|
+
// "react", "react-dom", "react-dom/server"
|
|
80
|
+
// "cookie"
|
|
81
|
+
],
|
|
82
|
+
exclude: [
|
|
83
|
+
"@rpcbase/auth", "@rpcbase/form", "@rpcbase/router", "react-router", "@radix-ui/*",
|
|
84
|
+
// "react", "react-dom/server",
|
|
85
|
+
// "react-hook-form",
|
|
86
|
+
// "react-dom"
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
export const extendConfig = (userConfig/*: Record<string, any>*/) => {
|
|
93
|
+
return defineConfig(mergeConfig(baseConfig, userConfig));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
export const createServer = async(config/* : Record<string, any>*/) => {
|
|
99
|
+
const extendedConfig = extendConfig(config)
|
|
100
|
+
delete extendedConfig.plugins
|
|
101
|
+
|
|
102
|
+
const viteServer = await viteCreateServer(extendedConfig)
|
|
103
|
+
|
|
104
|
+
return viteServer
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export const disableAppCache = (app) => {
|
|
109
|
+
app.set("etag", false)
|
|
110
|
+
|
|
111
|
+
app.use(nocache())
|
|
112
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rpcbase/vite",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"release": "wireit"
|
|
9
|
+
},
|
|
10
|
+
"wireit": {
|
|
11
|
+
"release": {
|
|
12
|
+
"command": "../../scripts/publish.js",
|
|
13
|
+
"dependencies": [],
|
|
14
|
+
"files": [
|
|
15
|
+
"package.json"
|
|
16
|
+
],
|
|
17
|
+
"output": [],
|
|
18
|
+
"env": {
|
|
19
|
+
"NPM_RELEASE_CHANNEL": {
|
|
20
|
+
"external": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@swc/core": "1.10.14",
|
|
27
|
+
"@tailwindcss/vite": "4.0.3",
|
|
28
|
+
"@vitejs/plugin-react-swc": "3.7.2",
|
|
29
|
+
"clsx": "2.1.1",
|
|
30
|
+
"libphonenumber-js": "1.11.19",
|
|
31
|
+
"mongoose": "8.10.0",
|
|
32
|
+
"nocache": "4.0.0",
|
|
33
|
+
"react": "19.0.0",
|
|
34
|
+
"react-dom": "19.0.0",
|
|
35
|
+
"react-router": "7.1.5",
|
|
36
|
+
"swc-plugin-add-display-name": "0.5.0",
|
|
37
|
+
"tailwindcss": "4.0.3",
|
|
38
|
+
"validator": "13.12.0",
|
|
39
|
+
"vite": "6.1.0",
|
|
40
|
+
"zod": "3.24.1"
|
|
41
|
+
}
|
|
42
|
+
}
|