Files
medusa-store/packages/admin/src/utils/load-config.ts
Kasper Fabricius Kristensen 8a7421db5b feat(admin): Improve DX for deploying admin externally (#3418)
* init deploy command

* add include flag

* add 'shortcut' flag

* add dev command, fix var replacement, change default behaviour

* cleanup params of build command

* fix defaults when using the plugin to serve admin

* add changeset

* fix globals

* update README

* throw error on no build found

---------

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-03-17 13:18:51 +01:00

34 lines
904 B
TypeScript

import { getConfigFile } from "medusa-core-utils"
import { ConfigModule, PluginOptions } from "../types"
export const loadConfig = () => {
const { configModule } = getConfigFile<ConfigModule>(
process.cwd(),
"medusa-config"
)
const plugin = configModule.plugins.find(
(p) =>
(typeof p === "string" && p === "@medusajs/admin") ||
(typeof p === "object" && p.resolve === "@medusajs/admin")
)
let defaultConfig: PluginOptions = {
serve: true,
autoRebuild: false,
path: "app",
}
if (typeof plugin !== "string") {
const { options } = plugin as { options: PluginOptions }
defaultConfig = {
serve: options.serve ?? defaultConfig.serve,
autoRebuild: options.autoRebuild ?? defaultConfig.autoRebuild,
path: options.path ?? defaultConfig.path,
outDir: options.outDir ?? defaultConfig.outDir,
}
}
return defaultConfig
}