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

Fix/serve command #22

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/morph/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
inertia_request_validation_exception_handler,
inertia_version_conflict_exception_handler,
)
from mangum import Mangum
from starlette.middleware.cors import CORSMiddleware
from starlette.middleware.sessions import SessionMiddleware

Expand Down Expand Up @@ -45,7 +46,8 @@ def get_inertia_config():
templates_dir = os.path.join(Path(__file__).resolve().parent, "templates")

if is_local_dev_mode:
frontend_url = "http://localhost:3000" # TODO: 被ったらずらす
front_port = os.getenv("MORPH_FRONT_PORT", "3000")
frontend_url = f"http://localhost:{front_port}"
templates = Jinja2Templates(directory=templates_dir)
templates.env.globals["local_dev_mode"] = True
templates.env.globals["frontend_url"] = frontend_url
Expand Down Expand Up @@ -153,3 +155,6 @@ async def subpages(full_path: str, inertia: InertiaDep) -> InertiaResponse:
"token": "dummy",
},
)


handler = Mangum(app)
6 changes: 0 additions & 6 deletions core/morph/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,7 @@ def sync(


@cli.command("serve")
@params.port
@params.host
@params.restart
@params.workdir
@params.stop
@params.build
@params.no_log
@params.preview
@click.pass_context
@global_flags
Expand Down
2 changes: 1 addition & 1 deletion core/morph/frontend/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --port",
"build": "tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
},
Expand Down
2 changes: 0 additions & 2 deletions core/morph/frontend/template/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ export default defineConfig((env) => ({
base: env.mode === "development" ? "" : "/_vite-static",
server: {
host: "0.0.0.0",
port: 3000,
open: false,
watch: {
usePolling: true,
disableGlobbing: false,
},
origin: env.mode === "development" ? "http://0.0.0.0:3000" : "",
},
resolve: {
alias: {
Expand Down
Loading
Loading