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>
This commit is contained in:
co-authored by
Oliver Windall Juhl
parent
9ad15d3a88
commit
8a7421db5b
@@ -1,8 +1,10 @@
|
||||
import dns from "dns"
|
||||
import fse from "fs-extra"
|
||||
import { resolve } from "path"
|
||||
import vite from "vite"
|
||||
import { AdminBuildConfig } from "./types"
|
||||
import { getCustomViteConfig } from "./utils"
|
||||
import { AdminDevConfig } from "./types/dev"
|
||||
import { getCustomViteConfig, getCustomViteDevConfig } from "./utils"
|
||||
|
||||
async function build(options?: AdminBuildConfig) {
|
||||
const config = getCustomViteConfig(options)
|
||||
@@ -25,4 +27,16 @@ async function clean() {
|
||||
throw new Error("Not implemented")
|
||||
}
|
||||
|
||||
export { build, watch, clean }
|
||||
async function dev(options: AdminDevConfig) {
|
||||
// Resolve localhost for Node v16 and older.
|
||||
// @see https://vitejs.dev/config/server-options.html#server-host.
|
||||
dns.setDefaultResultOrder("verbatim")
|
||||
|
||||
const server = await vite.createServer(getCustomViteDevConfig(options))
|
||||
await server.listen()
|
||||
|
||||
server.printUrls()
|
||||
}
|
||||
|
||||
export { build, dev, watch, clean }
|
||||
export type { AdminBuildConfig, AdminDevConfig }
|
||||
|
||||
Reference in New Issue
Block a user