chore: Update admin build/serve configuration (#9584)

**Breaking changes**

The `outDir` has been deprecated and wont be used anymore, instead all the path are computed internally following these rules
- if admin is not `disabled` and the `build` command is run without the `--admin-only` flag, then the admin output dir will be `.medusa/server/public/admin` and it will be served from that same location from the medusa instance.
- if admin is not `disabled` and the `build` command is run with the `--admin-only` flag, then the admin output dir will be `.medusa/admin` with the purpose of deploying the admin separately. ⚠️ (expect to receive a warning log)
- if the admin is `disabled` and the `build` command is run with the `--admin-only` flag, then fallback to rule number 2

| admin enabled  | medusa build --admin-only  | output dir |
|---|---|---|
| true  | true  | `.medusa/admin` ⚠️ (expect to receive a warning log) |
| true  | false  | `.medusa/server/public/admin`  |
| false  | true  | `.medusa/admin`  |
| false  | false  | none |

```diff
// medusa-config.ts

{
  // ...
  admin: {
-    outDir: 'some/path'
  }
}
```


cc @kasperkristensen @sradevski @olivermrbl
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-10-15 15:59:47 +00:00
1 parent 4a03bdbb86
commit 84fa6ccde5
9 files changed
+95 -48

No files matched your search

+4 -3
View File
@@ -3,6 +3,7 @@ import { AdminOptions, ConfigModule } from "@medusajs/framework/types"
import { Express } from "express"
import fs from "fs"
import path from "path"
import { ADMIN_RELATIVE_OUTPUT_DIR } from "../utils"
type Options = {
app: Express
@@ -10,10 +11,9 @@ type Options = {
rootDirectory: string
}
type IntializedOptions = Required<
Pick<AdminOptions, "path" | "disable" | "outDir">
> &
type IntializedOptions = Required<Pick<AdminOptions, "path" | "disable">> &
AdminOptions & {
outDir: string
sources?: string[]
}
@@ -39,6 +39,7 @@ export default async function adminLoader({
disable: false,
sources,
...admin,
outDir: path.join(rootDirectory, ADMIN_RELATIVE_OUTPUT_DIR),
}
if (adminOptions?.disable) {