@gxp-dev/tools 2.0.89 → 2.0.90
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/runtime/vite.config.js +24 -0
package/package.json
CHANGED
package/runtime/vite.config.js
CHANGED
|
@@ -191,6 +191,30 @@ export default defineConfig(async (ctx) => {
|
|
|
191
191
|
// Create plugin to serve runtime files (index.html and main.js) if no local ones exist
|
|
192
192
|
const runtimeFilesPlugin = {
|
|
193
193
|
name: "runtime-files",
|
|
194
|
+
// Resolve the legacy `/@gx-runtime/*` absolute-URL form used by
|
|
195
|
+
// runtime/index.html (and by any project index.html that hasn't
|
|
196
|
+
// migrated to the bare `@gx-runtime/...` specifier). Vite's
|
|
197
|
+
// resolve.alias map only catches bare specifiers, and the
|
|
198
|
+
// configureServer middleware below only catches HTTP requests —
|
|
199
|
+
// Vite's internal pre-transform of script-src URLs takes
|
|
200
|
+
// neither path and ends up logging
|
|
201
|
+
// "Pre-transform error: Failed to load url /@gx-runtime/main.js"
|
|
202
|
+
// every render tick. Returning the real filesystem path here
|
|
203
|
+
// short-circuits the resolution entirely so pre-transform, the
|
|
204
|
+
// dep optimizer, and SSR all agree on where the file lives.
|
|
205
|
+
resolveId(id) {
|
|
206
|
+
if (typeof id !== "string") return null
|
|
207
|
+
if (id.startsWith("/@gx-runtime/")) {
|
|
208
|
+
const relative = id.slice("/@gx-runtime/".length)
|
|
209
|
+
if (!relative) return null
|
|
210
|
+
// Strip any query string (e.g. ?t=12345 from HMR) before
|
|
211
|
+
// resolving against the filesystem.
|
|
212
|
+
const [bare, query] = relative.split("?")
|
|
213
|
+
const resolved = path.resolve(runtimeDir, bare)
|
|
214
|
+
return query ? `${resolved}?${query}` : resolved
|
|
215
|
+
}
|
|
216
|
+
return null
|
|
217
|
+
},
|
|
194
218
|
configureServer(server) {
|
|
195
219
|
server.middlewares.use((req, res, next) => {
|
|
196
220
|
// Serve runtime index.html for root requests and SPA navigation requests
|