@aklinker1/aframe 0.4.6 → 0.4.8
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/package.json +1 -1
- package/src/config.ts +20 -9
- package/src/env.d.ts +6 -1
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -5,8 +5,15 @@ import type { LaunchOptions } from "puppeteer";
|
|
|
5
5
|
|
|
6
6
|
export type UserConfig = {
|
|
7
7
|
vite?: vite.UserConfigExport;
|
|
8
|
+
/**
|
|
9
|
+
* Paths for vite to proxy to the backend during development.
|
|
10
|
+
* @default ["/api"]
|
|
11
|
+
*/
|
|
12
|
+
proxyPaths?: string[];
|
|
8
13
|
prerenderedRoutes?: string[];
|
|
9
14
|
prerenderer?: PrerendererConfig | false;
|
|
15
|
+
appPort?: number;
|
|
16
|
+
serverPort?: number;
|
|
10
17
|
};
|
|
11
18
|
|
|
12
19
|
export type PrerendererConfig = {
|
|
@@ -62,8 +69,6 @@ export async function resolveConfig(
|
|
|
62
69
|
const appOutDir = join(outDir, "public");
|
|
63
70
|
const serverOutDir = outDir;
|
|
64
71
|
const prerenderToDir = appOutDir;
|
|
65
|
-
const appPort = 3000;
|
|
66
|
-
const serverPort = 3001;
|
|
67
72
|
|
|
68
73
|
// Ensure required directories exist
|
|
69
74
|
await mkdir(prerenderToDir, { recursive: true });
|
|
@@ -74,12 +79,15 @@ export async function resolveConfig(
|
|
|
74
79
|
relativeConfigFile
|
|
75
80
|
);
|
|
76
81
|
|
|
82
|
+
const appPort = userConfig.appPort || 3000;
|
|
83
|
+
const serverPort = userConfig.serverPort || 3001;
|
|
84
|
+
|
|
77
85
|
let viteConfig = await vite.defineConfig((await userConfig.vite) ?? {});
|
|
78
86
|
if (typeof viteConfig === "function") {
|
|
79
87
|
viteConfig = await viteConfig({ command, mode });
|
|
80
88
|
}
|
|
81
|
-
// Apply opinionated config that can be overwritten
|
|
82
89
|
|
|
90
|
+
// Apply opinionated config that can be overwritten
|
|
83
91
|
viteConfig = vite.mergeConfig<vite.InlineConfig, vite.InlineConfig>(
|
|
84
92
|
// Defaults
|
|
85
93
|
{
|
|
@@ -93,6 +101,14 @@ export async function resolveConfig(
|
|
|
93
101
|
);
|
|
94
102
|
|
|
95
103
|
// Override required config
|
|
104
|
+
const proxyPaths = userConfig.proxyPaths ?? ["/api"];
|
|
105
|
+
const proxy: Record<string, string | vite.ProxyOptions> = {};
|
|
106
|
+
proxyPaths.forEach((path) => {
|
|
107
|
+
proxy[path] = {
|
|
108
|
+
target: `http://localhost:${serverPort}`,
|
|
109
|
+
changeOrigin: true,
|
|
110
|
+
};
|
|
111
|
+
});
|
|
96
112
|
viteConfig = vite.mergeConfig<vite.InlineConfig, vite.InlineConfig>(
|
|
97
113
|
// Defaults
|
|
98
114
|
viteConfig,
|
|
@@ -109,12 +125,7 @@ export async function resolveConfig(
|
|
|
109
125
|
server: {
|
|
110
126
|
port: appPort,
|
|
111
127
|
strictPort: true,
|
|
112
|
-
proxy
|
|
113
|
-
"/api": {
|
|
114
|
-
target: `http://localhost:${serverPort}`,
|
|
115
|
-
changeOrigin: true,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
128
|
+
proxy,
|
|
118
129
|
},
|
|
119
130
|
},
|
|
120
131
|
);
|
package/src/env.d.ts
CHANGED
|
@@ -2,7 +2,12 @@ import "vite/client";
|
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
interface ImportMeta {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Absolute path or relative path (relative to main server file, not CWD).
|
|
7
|
+
* This ensures the public directory path is constant regardless of the CWD.
|
|
8
|
+
* It allows dev mode, production builds, and preview mode to all run from
|
|
9
|
+
* any working directory.
|
|
10
|
+
*/
|
|
6
11
|
publicDir: string;
|
|
7
12
|
command: string;
|
|
8
13
|
}
|