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

getPlatformProxy does not build correctly when used #109

Open
yutakobayashidev opened this issue Mar 2, 2024 · 2 comments
Open

getPlatformProxy does not build correctly when used #109

yutakobayashidev opened this issue Mar 2, 2024 · 2 comments

Comments

@yutakobayashidev
Copy link
Contributor

yutakobayashidev commented Mar 2, 2024

What version of HonoX are you using?

0.1.5

What steps can reproduce the bug?

When I load wrangler.toml using getPlatformProxy and try to build it, the client build does not finish. Sorry if I am using it incorrectly.

import { defineConfig } from "vite";
import { getPlatformProxy } from "wrangler";
import honox from "honox/vite";
import clientBuild from "honox/vite/client";
import pagesBuild from "@hono/vite-cloudflare-pages";

export default defineConfig(async ({ mode }) => {
  const { env, dispose } = await getPlatformProxy();
  if (mode === "client") {
    return {
      plugins: [clientBuild()],
    };
  }
  return {
    plugins: [
      honox({
        devServer: {
          env,
          plugins: [
            {
              onServerClose: dispose,
            },
          ],
        },
      }),
      pagesBuild(),
    ],
  };
});

deps:

  "dependencies": {
    "@hono/vite-cloudflare-pages": "^0.2.5",
    "hono": "^4.0.8",
    "honox": "^0.1.5"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20240208.0",
    "vite": "^5.0.12",
    "wrangler": "^3.28.4"
  }
import { createRoute } from "honox/factory";

export default createRoute((c) => {
  return c.render(<h1>hi</h1>);
});

What is the expected behavior?

Environment variables must be loaded correctly and build must be completed

What do you see instead?

When I load wrangler.toml using getPlatformProxy and try to build it, the client build does not finish.

Export-1709395376579

@yutakobayashidev yutakobayashidev added the bug Something isn't working label Mar 2, 2024
@yutakobayashidev yutakobayashidev changed the title getPlatformProxy does not build correctly getPlatformProxy does not build correctly when used Mar 2, 2024
@yutakobayashidev
Copy link
Contributor Author

I found a related workaround:
https://twitter.com/yusukebe/status/1760527881019719985

@yusukebe
Copy link
Member

yusukebe commented Mar 2, 2024

Hi @yutakobayashidev

That's not a bug. Please try this config while we are looking for a shorter way:

import { defineConfig } from 'vite'
import { getPlatformProxy } from 'wrangler'
import honox from 'honox/vite'
import clientBuild from 'honox/vite/client'
import pagesBuild from '@hono/vite-cloudflare-pages'

export default defineConfig(async ({ mode, command }) => {
  if (mode === 'client') {
    return {
      plugins: [clientBuild()]
    }
  }
  if (command === 'build') {
    return {
      plugins: [honox(), pagesBuild()]
    }
  }
  const { env, dispose } = await getPlatformProxy()
  return {
    plugins: [
      honox({
        devServer: {
          env,
          plugins: [
            {
              onServerClose: dispose
            }
          ]
        }
      }),
      pagesBuild()
    ]
  }
})

@yusukebe yusukebe removed the bug Something isn't working label Mar 2, 2024
justinnoel added a commit to justinnoel/hono-x-vite-test that referenced this issue Mar 3, 2024
MIDO-ruby7 added a commit to MIDO-ruby7/kanzen-ni-rikaishita that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants