Generate a Vue 3 + Pinia full-stack boilerplate with module federation. Structure it so Dashboard and Settings are separate micro-frontends that deploy independently but load into the main shell app at runtime.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I'm defining a minimal full-stack boilerplate with a shell app hosting two remotes via webpack 5 Module Federation, sharing Vue and Pinia singleton dependencies, exposing remote components under ./Module for async import by the shell router, and configuring dev servers and shared stores accordingly. Next, I'll produce key config files and minimal source samples for shell, dashboard, and settings projects.
Below is a minimal, working Module Federation boilerplate for Vue 3 + Pinia with three separate apps:
shell (host) – main shell that loads remotes at runtime
dashboard (remote) – deploys independently
settings (remote) – deploys independently
Each app is separately deployable (e.g., different repos or CI pipelines). They share vue and pinia as singletons so the host and remotes all use the same runtime instances. You can keep them in a monorepo (e.g., pnpm/yarn workspaces) or split them into separate repos.
Directory layout (example)
code
project-root/
shell/
package.json
webpack.config.js
src/
main.ts
App.vue
router.ts
store.ts
shims-vue.d.ts
dashboard/
package.json
webpack.config.js
src/
main.ts # (usually not used when loaded as remote)
bootstrap.ts
App.vue
router.ts
store.ts
shims-vue.d.ts
settings/
package.json
webpack.config.js
src/
main.ts # (usually not used when loaded as remote)
bootstrap.ts
App.vue
router.ts
store.ts
shims-vue.d.ts
Each app uses webpack 5 with @vue/compiler-sfc, vue-loader, and @vue/shared. We’ll use TypeScript for entry files; you can swap to JavaScript if you prefer.
Common dependencies (all apps)
bash
# in each app folder (shell/dashboard/settings)
npm i vue@^3.3.0 pinia@^2.1.0 vue-router@^4.2.0
npm i -D webpack@^5 webpack-cli@^5 webpack-dev-server@^4 \
@webpack-cli/serve@^1 vue-loader@^17 \
@vue/compiler-sfc@^3.3.0 ts-loader@^9 typescript@^5 \
css-loader@^6 style-loader@^3 html-webpack-plugin@^5 \
webpack-merge@^5 @types/node
Note: The dashboard can also run standalone by hitting localhost:3001. The same compiled bundle is used as remote via remoteEntry.js.
dashboard/src/bootstrap.ts (what the shell loads)
ts
import { defineAsyncComponent, defineComponent, h } from 'vue';
import App from './App.vue';
import router from './router';
import { createPinia } from 'pinia';
export default defineComponent({
name: 'DashboardRemoteWrapper',
setup() {
// We create a local app instance when used standalone; in module federation, we mount as component.
return () =>
h(App, {
// If you want to pass props from shell to remote, define them on App and pass here.
});
},
});
// If you prefer to directly expose your top-level component (App.vue), just do:
// export default App;
dashboard/src/main.ts (standalone dev entry)
ts
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import { createPinia } from 'pinia';
const app = createApp(App);
app.use(createPinia());
app.use(router);
app.mount('#app');
dashboard/src/App.vue
vue
<template>
<div class="dashboard">
<h2>Dashboard (Remote)</h2>
<p>This is served from the dashboard MF at port 3001.</p>
<router-view />
</div>
</template>
dashboard/src/router.ts
ts
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import DashboardHome from './pages/DashboardHome.vue';
const routes: Array<RouteRecordRaw> = [
{ path: '/', name: 'DashboardHome', component: DashboardHome },
];
export default createRouter({
history: createWebHistory(), // note: for MF embed, the shell's router controls base; typically fine
routes,
});
dashboard/src/pages/DashboardHome.vue
vue
<template>
<section>
<h3>Dashboard Home</h3>
<p>Data from the Dashboard micro-frontend.</p>
</section>
</template>
<template>
<section>
<h3>Settings Home</h3>
<p>Data from the Settings micro-frontend.</p>
</section>
</template>
Sharing Pinia & Vue Router
The shared config in each ModuleFederationPlugin ensures that vue, pinia, and vue-router are singletons. In the shell, you create the Pinia instance once and mount the shell app. Each remote still uses Pinia if it needs local store. If you want to share a single root Pinia store across MFEs, you can expose the store from the shell and re-use it from remotes, but this minimal boilerplate keeps each remote self-contained.
Running locally
In three separate terminals (or via a monorepo script):
bash
# shell
cd shell
npm install
npm run dev # or webpack serve
# dashboard
cd dashboard
npm install
npm run dev
# settings
cd settings
npm install
npm run dev
When you navigate to /dashboard or /settings in the shell, it loads the remote code at runtime.
Production build
Each app is built independently:
bash
# in each folder
npm run build
Then deploy dist/ to your static host. In production, update remote URLs in the shell’s ModuleFederation config to point to the deployed remoteEntry.js of each micro-frontend.
Each micro-frontend can call this API via fetch/axios. This stays independent from module federation.
This boilerplate demonstrates Vue 3 + Pinia + Module Federation with two independently deployable micro-frontends (dashboard, settings) loaded by a shell at runtime. You can extend it with CI/CD pipelines per project, a shared design system, or a shared store if desired.