Replies: 4 comments
-
Hey, I'm not entirely sure if this'll work, vinxi looks like it as a property called This could be wrong but, I'd try something like: // app.config.ts
import { defineConfig } from "@solidjs/start/config";
import { App } from "vinxi";
const config = defineConfig();
changeStaticBasePath("https://example.cloudfront.net/", config)
export default config;
function changeStaticBasePath(basePath: string, config: App) {
config.stack(async (app) => {
const staticRouter = app.config.routers.find(router => router.name == 'public')
if (staticRouter) {
staticRouter.base = basePath
} else {
throw new Error("Static router not found")
}
})
} |
Beta Was this translation helpful? Give feedback.
-
Thank you for your input @doeixd. Digging a bit into the issue Cannot read properties of undefined (reading 'file'), the issue come from } else if (router.target === "browser") {
const id =
input === router.handler && !input.endsWith(".html")
? virtualId(handlerModule(router))
: input;
return {
import() {
return import(
/* @vite-ignore */ joinURL(
app.config.server.baseURL ?? "",
router.base,
bundlerManifest[id].file,
)
);
},
assets() {
return createHtmlTagsForAssets(
router,
app,
findAssetsInViteManifest(bundlerManifest, id),
);
},
output: {
path: joinURL(
app.config.server.baseURL ?? "",
router.base,
bundlerManifest[id].file,
),
},
};
} It is a bit different that what I initially thought on delivering static assets. |
Beta Was this translation helpful? Give feedback.
-
Hmmm. I think I got the purpose of import { defineConfig } from "@solidjs/start/config";
import { App } from "vinxi";
const config = defineConfig();
changeStaticBasePath({ proxyTo: "https://example.cloudfront.net/"} , config)
export default config;
function changeStaticBasePath(basePath: {
serveFrom?: `/${string}`
proxyTo?: string
}, config: App) {
if (!basePath.serveFrom) basePath.serveFrom = "/public"
// @ts-expect-error
basePath.serveFrom = '/' + basePath.serveFrom.replace(/\/$/, "").replace(/^\//, "")
config.stack(async (app) => {
const staticRouter = app.config.routers.find(router => router.name == 'public')
if (staticRouter) {
if (basePath.serveFrom) {
staticRouter.base = basePath.serveFrom
}
if (basePath.proxyTo) {
app.config.server.routeRules ||= {}
app.config.server.routeRules[`${basePath.serveFrom}/**`] = {
proxy: basePath.proxyTo
}
}
} else {
throw new Error("Static router not found")
}
})
} |
Beta Was this translation helpful? Give feedback.
-
It turns out that there was no issue related to static assets. No need to even use The line if (id === "virtual:#vinxi/handler/client") {
id = id.replace("#", "$");
} |
Beta Was this translation helpful? Give feedback.
-
Hi,
I recently started playing around with solid-start and I use the starter code with:
I learned about the fact that under the hood solid-start uses
vinxi
that is a smart way to combinevite
andnitro
. For the deployment I wanted to useterraform
instead of solutions listed here and thanks tonitro
preset I thought this could be as easy as:I did not really understand what to do with the
outputs
(public
andserver
folder). Thanks to that guide I've use a Cloudfront distribution that points to S3 for static assets (example with favicon) and lambda for the rendering of the application but that is not working (Cannot read properties of undefined (reading 'file')).I later found that
defineNuxtConfig
usescdnURL
for static assets but I was not able to find the same onvinxi
.Do you guys have any ideas how to get the correct build for AWS Lambda with SSR and deliver static assets through a cdn ?
For the lambda code I've only used the
server
folder (vinxi
outputs). Do I need to use thepublic
one as well ?Also posted here.
Beta Was this translation helpful? Give feedback.
All reactions