diff --git a/README.md b/README.md index 0c2f654..5af3efb 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,14 @@ MFE with Nuxt being the Host and Remote +## Initial setup + ``` -cd host -pnpm i -pnpm build -pnpm serve +cp .env.example .env ``` +## Development + ``` cd remote pnpm i @@ -16,8 +17,30 @@ pnpm build pnpm serve ``` -# TODO +``` +cd host +pnpm i +pnpm dev +``` -- Build-mode works but Dev-mode not works +Open http://localhost:3000 + +## Deployment + +``` +cd remote +pnpm i +pnpm build +pnpm serve + +cd host +pnpm i +pnpm build +pnpm serve +``` + +## TODO + +- Build-mode works but Dev-mode not works (fixed) - Enable CORS on remote JS assets (fixed) - Scoped style still not works (fixed) diff --git a/host/.env.example b/host/.env.example new file mode 100644 index 0000000..8708181 --- /dev/null +++ b/host/.env.example @@ -0,0 +1 @@ +NUXT_MFE_APP1_HOST=http://localhost:3001 diff --git a/host/nuxt.config.ts b/host/nuxt.config.ts index 8f52eea..e08bdda 100644 --- a/host/nuxt.config.ts +++ b/host/nuxt.config.ts @@ -2,6 +2,8 @@ import { defineNuxtConfig } from "nuxt/config" import federation from "@originjs/vite-plugin-federation" import topLevelAwait from "vite-plugin-top-level-await" +const MFE_HOST = process.env.NUXT_MFE_APP1_HOST + export default defineNuxtConfig({ compatibilityDate: "2024-04-03", devtools: { enabled: false }, @@ -29,7 +31,7 @@ export default defineNuxtConfig({ federation({ name: "host-app", remotes: { - remote: "http://localhost:3001/_nuxt/remoteEntry.js" + remote: `${MFE_HOST}/_nuxt/remoteEntry.js` }, shared: ["vue"] })