-
Notifications
You must be signed in to change notification settings - Fork 38
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
when use vite-build, how to change the port in the production ? nodejs plateform #195
Comments
@JsonSong89 我放弃用这个打包了, 改用tsup, 轻松加愉快 |
确实,hono是个好框架,但vite还是不太适配 |
I want to change the port, but no way to do so.. |
哈哈 我寻思这框架也不是国产啊,怎么都是国人... |
看了下源码,发现还是留了一个hook: {
plugins: [
build({
entry: "./src/apps/hello.ts",
output: "hono_hello.mjs",
minify: false,
entryContentAfterHooks: [(appName, options) => {
console.log("entryContentAfterHooks 触发")
return `
import {serve} from '@hono/node-server'
const run_port = parseInt(process.env.PORT) || 3002
serve({
fetch: ${appName}.fetch,
port: run_port,
}, info => {
console.log(\`Server is running on \${JSON.stringify(info)}\`);
})
`
}]
}),
devServer({
entry: "./src/apps/hello.ts"
}),
]
} |
tsup 也有问题 |
The This is fixed by #198 |
ok. thank you |
when i write code like below, and then run
vite build
, and runnode dist/index.js
, trigger error`
import { Hono } from "hono";
const app = new Hono();
app.get("/", (c) => {
return c.text("Hello Hono!4");
});
export default {
fetch: app.fetch,
port: 3333,
};
`
TypeError: Cannot read properties of undefined (reading 'map')
at It.route (file:///Users/sperains/rainswork/hono_app/dist/index.js:1:12694)
at file:///Users/sperains/rainswork/hono_app/dist/index.js:1:29432
at ModuleJob.run (node:internal/modules/esm/module_job:268:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:543:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
Node.js v22.11.0
if i write code like this, it will start two server port, 3000 and 3333
`
import { serve } from "@hono/node-server";
import { Hono } from "hono";
const app = new Hono();
const isProd = process.env["NODE_ENV"] === "production";
app.get("/", (c) => {
return c.text("Hello Hono!4");
});
if (isProd) {
serve({
fetch: app.fetch,
port: 3333,
});
}
export default app;
`
what's wrong about this? sure, i am a Fish. is there anyone who can tell me how to do it ?
The text was updated successfully, but these errors were encountered: