Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Missing/no images using vite-imagetools in dev mode #1195

Closed
2 tasks done
jaroel opened this issue Dec 29, 2023 · 5 comments · Fixed by #1198
Closed
2 tasks done

[Bug]: Missing/no images using vite-imagetools in dev mode #1195

jaroel opened this issue Dec 29, 2023 · 5 comments · Fixed by #1198
Labels
bug Something isn't working

Comments

@jaroel
Copy link

jaroel commented Dec 29, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Running pnpm run dev results in no images (w/ vite-imagetools).
Running pnpm run build results in a beautiful page with nicely resized images :)

Expected behavior 🤔

I'd like to see images when running pnpm run dev too please :)

Steps to reproduce 🕹

Steps:

  1. clone https://github.com/jaroel/solid-start-imagetools
  2. pnpm install && pnpm run dev
  3. load / and see something like the following image:
Screenshot 2023-12-29 at 02 00 54

Context 🔦

I want to resize images when building the website.

Your environment 🌎

Macos
node v20.9.0
@jaroel jaroel added the bug Something isn't working label Dec 29, 2023
@brenelz
Copy link
Contributor

brenelz commented Dec 29, 2023

I think this is a related pr that needs to be ported to vinxi

https://github.com/nuxt/framework/pull/9602/files.

This seems to fix it:

const viteServer = await createViteHandler(router, app, serveConfig);
const handler = eventHandler(async (event) => {
	const originalURL = event.node.req.url;
	let base = join(app.config.server.baseURL ?? "/", router.base);
	// @ts-expect-error _skip_transform is a private property
	event.node.req._skip_transform = !originalURL.startsWith(base);

	const { default: handler } = await viteServer.ssrLoadModule(
		handlerModule(router),
	);
	return handler(event);
});

@nksaraf
Copy link
Member

nksaraf commented Dec 29, 2023

can you make a PR for this in vinxi? we should include this if it fixes things

@brenelz
Copy link
Contributor

brenelz commented Dec 29, 2023

Alright i created a pr that seems to fix things. I am just unsure of any other negative affects

@nksaraf
Copy link
Member

nksaraf commented Dec 30, 2023

Released a new version of vinxi (0.0.61) that fixes this. Give it a try (use this package.json).

{
  "name": "snuk",
  "type": "module",
  "scripts": {
    "dev": "vinxi dev",
    "build": "vinxi build",
    "start": "vinxi start"
  },
  "dependencies": {
    "@solidjs/meta": "^0.29.2",
    "@solidjs/router": "^0.10.5",
    "@solidjs/start": "^0.4.2",
    "@vinxi/server-functions": "0.0.58",
    "solid-js": "^1.8.7",
    "vinxi": "0.0.61"
  },
  "engines": {
    "node": ">=18"
  },
  "devDependencies": {
    "vite-imagetools": "^6.2.8"
  },
  "pnpm": {
    "overrides": {
      "@vinxi/server-functions": "0.0.58"
    }
  }
}

@nksaraf nksaraf closed this as completed Dec 30, 2023
@jaroel
Copy link
Author

jaroel commented Dec 30, 2023

This works for me, thank both! FYI: I didn't need to use the pnpm overrides block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants