Skip to content

Commit 327b3b8

Browse files
committed
c
1 parent 8cb08af commit 327b3b8

9 files changed

+358
-126
lines changed

.env.prod

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VUE_APP_REMOTES=heroku

package-lock.json

+295-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"serve": "vue-cli-service serve",
7-
"build": "vue-cli-service build",
6+
"serve": "vue-cli-service serve --mode local",
7+
"build": "vue-cli-service build --mode prod",
88
"lint": "vue-cli-service lint",
99
"start": "node server.js"
1010
},
1111
"dependencies": {
1212
"core-js": "^3.8.3",
1313
"cors": "^2.8.5",
14+
"element-plus": "^2.1.4",
1415
"moment": "^2.29.1",
15-
"primeicons": "^5.0.0",
16-
"primevue": "^3.12.1",
1716
"vue": "^3.2.13",
1817
"vue-router": "^4.0.14",
1918
"vuex": "^4.0.2"

src/MfeTwo-App.vue

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<template>
22
<div>
3-
<h1>{{ "Micro Frontend Two (Vue 3 + Prime Faces)" }}</h1>
43
<div class="login-info">
54
<div class="logged" v-if="logged">Logged in as {{ userLabel }}</div>
65
<div class="not-logged" v-else>Not Logged</div>
76
</div>
87
<router-link to="/">Route 1</router-link>
9-
<br />
10-
<router-link to="/mfetwo-route2">Route 2</router-link>
8+
<router-link style="margin-left: 10px" to="/mfetwo-route2"
9+
>Route 2</router-link
10+
>
11+
<h1>{{ "Micro Frontend Two (Vue 3 + Element Plus)" }}</h1>
1112
<br />
1213
<div v-if="logged" style="margin-top: 20px">
13-
<router-view v-slot="{ Component }">
14+
<router-view v-slot="{ Component }">
1415
<keep-alive>
1516
<component :is="Component" />
1617
</keep-alive>
@@ -21,29 +22,28 @@
2122

2223
<script>
2324
import { auth$ } from "ModuleAuth/ModuleAuth";
24-
import { computed } from 'vue'
25+
import { computed } from "vue";
2526
import { useStore } from "vuex";
2627
2728
export default {
2829
name: "MfeTwo-App",
29-
components: {
30-
},
30+
components: {},
3131
setup() {
3232
const store = useStore();
3333
34-
const logged = computed(() => store.getters.getLoggedIn)
35-
const userLabel = computed(() => store.getters.getUserLabel)
34+
const logged = computed(() => store.getters.getLoggedIn);
35+
const userLabel = computed(() => store.getters.getUserLabel);
3636
3737
auth$.subscribe((payload) => {
38-
store.dispatch('setAuth', payload)
38+
store.dispatch("setAuth", payload);
3939
});
4040
41-
store.dispatch('getStepsGeneric')
41+
store.dispatch("getStepsGeneric");
4242
4343
return {
4444
logged,
45-
userLabel
46-
}
45+
userLabel,
46+
};
4747
},
4848
};
4949
</script>

src/bootstrap.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import { createApp } from 'vue'
22
import MfeTwoApp from './MfeTwo-App.vue'
33
import { createRouter, createWebHashHistory } from "vue-router";
44

5-
import PrimeVue from 'primevue/config';
5+
import ElementPlus from 'element-plus'
6+
import 'element-plus/dist/index.css'
67

78
import store from './store/store'
89

910
import RouteOne from './views/MfeTwo-RouteOne'
1011
import RouteTwo from './views/MfeTwo-RouteTwo'
1112

12-
import 'primevue/resources/themes/saga-blue/theme.css';
13-
import 'primevue/resources/primevue.min.css';
14-
import 'primeicons/primeicons.css';
15-
1613
const routes = [
1714
{ path: '/', component: RouteOne },
1815
{ path: '/mfetwo-route2', component: RouteTwo },
@@ -28,7 +25,7 @@ const mount = (el) => {
2825
const app = createApp(MfeTwoApp)
2926
app.use(router)
3027
app.use(store)
31-
app.use(PrimeVue)
28+
app.use(ElementPlus)
3229
app.mount(el)
3330
};
3431

+2-41
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,3 @@
11
<template>
2-
<div class="p-fluid grid formgrid">
3-
<div class="field col-12 md:col-4" style="width: 200px">
4-
<Calendar id="basic" v-model="date1" autocomplete="off"></Calendar>
5-
</div>
6-
</div>
7-
</template>
8-
9-
<script>
10-
import Calendar from 'primevue/calendar/sfc';
11-
import { ref } from "vue";
12-
export default {
13-
components: {
14-
Calendar
15-
},
16-
setup() {
17-
const date1 = ref(new Date());
18-
19-
return { date1 };
20-
},
21-
};
22-
</script>
23-
24-
<style>
25-
.card-header {
26-
display: flex;
27-
justify-content: space-between;
28-
align-items: center;
29-
}
30-
31-
.text {
32-
font-size: 14px;
33-
}
34-
35-
.item {
36-
margin-bottom: 18px;
37-
}
38-
39-
.box-card {
40-
width: 480px;
41-
}
42-
</style>
2+
<el-calendar :range="[new Date(2019, 2, 4), new Date(2019, 2, 24)]" />
3+
</template>

src/components/MainComponent.vue renamed to src/components/MfeTwo-MainComponent.vue

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
<template>
22
<div class="hello" style="position: relative">
3-
<div><MfeTwoChildComponent /></div>
4-
<div class="shared-comp">
5-
<SharedComponent />
6-
</div>
7-
<div class="shared-comp-2">
8-
<SharedComponentGeneric :steps="store.state.stepsGeneric" />
9-
</div>
103

11-
{{ moment().format("MMMM Do YYYY, h:mm:ss a") }}
4+
<el-row :gutter="50">
5+
<el-col :span="8"
6+
><div class="grid-content bg-purple" />
7+
<MfeTwoChildComponent />
8+
</el-col>
9+
<el-col :span="8"
10+
><div class="grid-content bg-purple" />
11+
<div class="shared-comp">
12+
<SharedComponent />
13+
</div>
14+
</el-col>
15+
<el-col :span="8"
16+
><div class="grid-content bg-purple" />
17+
<div class="shared-comp-2">
18+
<SharedComponentGeneric :steps="store.state.stepsGeneric" />
19+
</div>
20+
</el-col>
21+
</el-row>
22+
23+
Moment.js <br /> {{ moment().format("MMMM Do YYYY, h:mm:ss a") }}
1224
<br />
13-
<span style="color: #409eff">{{ message }}</span>
25+
<span style="color: #409eff">Message from MfeOne: {{ message }}</span>
1426
</div>
1527
</template>
1628

@@ -73,17 +85,12 @@ a {
7385
.shared-comp {
7486
background-color: lightgray;
7587
padding: 10px;
76-
width: 400px;
77-
margin-top: 10px;
78-
margin-left: 40%;
88+
width: 100%;
7989

8090
}
8191
.shared-comp-2 {
8292
background-color: lightseagreen;
8393
padding: 10px;
84-
width: 400px;
85-
margin-top: 10px;
86-
margin-left: 40%;
87-
94+
width: 100%;
8895
}
8996
</style>

src/views/MfeTwo-RouteOne.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<script>
8-
import MfeTwoMainComponent from "../components/MainComponent.vue";
8+
import MfeTwoMainComponent from "../components/MfeTwo-MainComponent.vue";
99
1010
export default {
1111
name: "RouteOne",

vue.config.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const ModuleFederationPlugin = require('webpack').container.ModuleFederationPlug
33
const deps = require("./package.json");
44
module.exports = defineConfig({
55
transpileDependencies: true,
6-
publicPath: 'https://module-federation-mfe-two.herokuapp.com/',
6+
publicPath: process.env.VUE_APP_REMOTES === 'local' ?
7+
// DEVELOPMENT
8+
'http://localhost:9998/' :
9+
// PRODUCTION
10+
'https://module-federation-mfe-two.herokuapp.com/',
711
devServer: { port: 9998 },
812
configureWebpack: {
913
optimization: {
@@ -16,24 +20,27 @@ module.exports = defineConfig({
1620
new ModuleFederationPlugin({
1721
name: 'MfeTwo',
1822
filename: 'remoteEntry.js',
19-
remotes: {
20-
ModuleAuth: 'ModuleAuth@https://module-federation-module-auth.herokuapp.com/remoteEntry.js',
21-
// MfeOne: 'MfeOne@http://localhost:9999/remoteEntry.js',
22-
MfeOne: 'MfeOne@https://module-federation-mfe-one.herokuapp.com/remoteEntry.js',
23-
},
23+
remotes: process.env.VUE_APP_REMOTES === 'local' ?
24+
// DEVELOPMENT
25+
{
26+
ModuleAuth: 'ModuleAuth@http://localhost:9898/remoteEntry.js',
27+
MfeOne: 'MfeOne@http://localhost:9999/remoteEntry.js',
28+
} :
29+
// PRODUCTION
30+
{
31+
ModuleAuth: 'ModuleAuth@https://module-federation-module-auth.herokuapp.com/remoteEntry.js',
32+
MfeOne: 'MfeOne@https://module-federation-mfe-one.herokuapp.com/remoteEntry.js',
33+
},
2434
exposes: {
25-
'./MfeTwo': './src/bootstrap.js' // implica wrapper en consumer que use el mount exportado por main
26-
//'./MfeTwo': './src/components/MfeTwo-MainComponent.vue'
35+
'./MfeTwo': './src/bootstrap.js'
2736
},
2837
shared: {
2938
vue: {
30-
// eager: true,
3139
singleton: true,
3240
requiredVersion: deps.vue
3341
},
3442
...require('./package.json').dependencies
3543
},
36-
//shared: require('./package.json').dependencies,
3744
})
3845
]
3946
}

0 commit comments

Comments
 (0)