Skip to content

Commit

Permalink
(fix): static assets imports in server side handler
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Dec 27, 2023
1 parent 9274a65 commit e7afb6e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions examples/solid/ssr/basic/app/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Counter } from "./Counter";
import Logo from "./logo.png";
import "./style.css";

export default function App({ assets, scripts }) {
Expand All @@ -11,6 +12,7 @@ export default function App({ assets, scripts }) {
<body>
<section>
<h1>Hello AgentConf with ya asdo!!!</h1>
<img src={Logo} />
<Counter />
</section>
{scripts}
Expand Down
Binary file added examples/solid/ssr/basic/app/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions examples/solid/ssr/basic/app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
@tailwind components;
@tailwind utilities;

html {
@apply bg-black;
}

* {
color: green;
}
color: green;
}
4 changes: 2 additions & 2 deletions packages/vinxi/lib/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ export async function createDevServer(
await devApp.close();
await Promise.all(
app.config.routers
.filter(router => router.internals.devServer)
.map(router => router.internals.devServer?.close())
.filter((router) => router.internals.devServer)
.map((router) => router.internals.devServer?.close()),
);
},
};
Expand Down
10 changes: 10 additions & 0 deletions packages/vinxi/lib/router-modes.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ const routerModes = {
handler: createRouterMode(handlerRouterSchema, {
name: "handler",
dev: {
publicAssets: (router) => {
/**
* Added here to support static asset imports. Vite transforms these using the server base path. During development it expects that the file system will be available. So we need to serve the whole src diectory (including node_modules) during dev.
*/
return {
dir: join(router.root),
baseURL: router.base,
fallthrough: true,
};
},
plugins: async (router) => {
const { ROUTER_MODE_DEV_PLUGINS } = await import(
"./router-dev-plugins.js"
Expand Down

0 comments on commit e7afb6e

Please sign in to comment.