Skip to content

Commit 895eabe

Browse files
Submit rsbuild vue 3 vuex tailwindcss postcss example (#4143)
* rsbuild vue 3 vuex example * update read me * remove commented files --------- Co-authored-by: Zack Jackson <[email protected]>
1 parent 04381f4 commit 895eabe

28 files changed

+6171
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Module federation will work with any type of file that you're able to import, th
8484
- Shopify
8585
- adidas
8686
- Zomato
87+
- PayNet (Payments Network Malaysia)
8788
- and many more I cant remember
8889

8990
# Contribution to this repo

rsbuild-vue3-vuex/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Project Setup and rsbuild vue 3 vuex tailwindcss postcss example:
2+
3+
4+
## Setup Instructions
5+
6+
### 1. Clone the Repository
7+
8+
```bash
9+
git clone <repository-url>
10+
cd <repository-folder>
11+
```
12+
13+
### 2. Install Dependencies
14+
15+
You need to install dependencies for both the Provider and consumer folders.
16+
17+
#### In the Provider Folder
18+
19+
```bash
20+
cd provider
21+
yarn install
22+
```
23+
24+
#### In the Consumer Folder
25+
26+
Open a new terminal or navigate back to the root folder and then:
27+
28+
```bash
29+
cd consumer
30+
yarn install
31+
```
32+
33+
### 3. Run the Application
34+
35+
#### In the Consumer Folder
36+
37+
```bash
38+
yarn dev
39+
```
40+
41+
## Additional Notes
42+
43+
- Ensure that both the provider and consumer folders have their dependencies installed before running the application.

rsbuild-vue3-vuex/consumer/.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Local
2+
.DS_Store
3+
*.local
4+
*.log*
5+
6+
# Dist
7+
node_modules
8+
dist/
9+
10+
# IDE
11+
.vscode/*
12+
!.vscode/extensions.json
13+
.idea
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "osp-dispute-management",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "rsbuild dev --open",
7+
"build": "rsbuild build",
8+
"preview": "rsbuild preview"
9+
},
10+
"dependencies": {
11+
"vue": "3.2.31",
12+
"vue-router": "^4.0.13",
13+
"vuex": "^4.1.0"
14+
},
15+
"devDependencies": {
16+
"@module-federation/enhanced": "^0.1.19",
17+
"tailwindcss": "^3.0.24",
18+
"@rsbuild/core": "^0.7.9",
19+
"@rsbuild/plugin-vue": "^0.7.9",
20+
"typescript": "^5.4.5"
21+
},
22+
"license": "MIT"
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
},
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { defineConfig } from "@rsbuild/core";
2+
import { pluginVue } from "@rsbuild/plugin-vue";
3+
// import { pluginEslint } from '@rsbuild/plugin-eslint';
4+
import path from "node:path";
5+
import { dependencies } from "./package.json";
6+
import { ModuleFederationPlugin } from "@module-federation/enhanced/rspack";
7+
8+
export default defineConfig({
9+
source: {
10+
entry: {
11+
index: "./src/main.js",
12+
},
13+
},
14+
server: {
15+
port: 3000,
16+
},
17+
output: {
18+
assetPrefix: '/',
19+
filenameHash: true,
20+
},
21+
tools: {
22+
rspack: (config, { appendPlugins }) => {
23+
// Will work in dev only if set to "/"
24+
config.resolve ||= {};
25+
config.resolve.alias ||= {};
26+
config.output ||= {};
27+
// public
28+
config.resolve.alias["@"] = path.resolve(__dirname, "src");
29+
appendPlugins([
30+
new ModuleFederationPlugin({
31+
name: `ASSET_HOST`,
32+
filename: `ASSET_HOST__remoteEntry.js`,
33+
remotes: {
34+
"@remote": "ASSET_REMOTE@http://localhost:3001/remoteEntry.js",
35+
},
36+
shared: {
37+
vue: {
38+
singleton: true,
39+
requiredVersion: dependencies.vue,
40+
},
41+
vuex: {
42+
singleton: true,
43+
requiredVersion: dependencies.vuex,
44+
},
45+
},
46+
}),
47+
]);
48+
},
49+
},
50+
plugins: [pluginVue({
51+
splitChunks: {
52+
vue: false,
53+
router: false
54+
}
55+
})],
56+
});
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script>
2+
export default {
3+
name: "App",
4+
};
5+
</script>
6+
<template>
7+
<div :class="$style.view">
8+
<div :class="$style.main">
9+
<router-view />
10+
</div>
11+
</div>
12+
</template>
13+
14+
<style module scoped>
15+
.view {
16+
@apply min-h-screen overflow-hidden bg-gray-100 print:!overflow-visible print:invisible print:h-full;
17+
}
18+
19+
.main {
20+
@apply m-auto;
21+
}
22+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { createApp } from "vue";
2+
import App from "./App.vue";
3+
import router from "./router";
4+
import store from "./store";
5+
const app = createApp(App);
6+
7+
export const bootstrap = () => {
8+
app
9+
.use(store(app))
10+
.use(router)
11+
.mount("#root");
12+
};
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import("./bootstrap").then(({ bootstrap }) => bootstrap());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { createRouter, createWebHistory } from "vue-router";
2+
import routes from "./routes";
3+
4+
const router = createRouter({
5+
hashbang: false,
6+
mode: "history",
7+
history: createWebHistory("/"),
8+
base: "/",
9+
routes,
10+
});
11+
12+
export default router;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
const routes = [
3+
{
4+
path: "/",
5+
name: "index",
6+
component: () => import("@/views/Index.vue"),
7+
},
8+
];
9+
10+
export default routes;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createStore } from "vuex";
2+
import { remoteStore } from "@remote/store";
3+
4+
const searchInput = {
5+
state: {
6+
queryData: null,
7+
},
8+
mutations: {},
9+
};
10+
11+
export default (app) =>
12+
createStore({
13+
...remoteStore,
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script>
2+
import AppIndex from "@remote/AppIndex";
3+
4+
export default {
5+
name: "HostIndex",
6+
components: {
7+
AppIndex,
8+
},
9+
setup() { },
10+
computed: {
11+
userData() {
12+
return this.$store.state.userData;
13+
},
14+
initialLoaded() {
15+
return this.$store.state.initialLoaded;
16+
},
17+
},
18+
mounted() {
19+
this.$store
20+
.dispatch("getUserData")
21+
.catch((err) => {
22+
console.log(err);
23+
})
24+
.then((message) => {
25+
console.log(message)
26+
});
27+
},
28+
};
29+
</script>
30+
31+
<template>
32+
<p> Hi There, this is consumer app. I'm loading userData from remote : {{ userData }}</p>
33+
<AppIndex>
34+
<router-view />
35+
</AppIndex>
36+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const defaultTheme = require("tailwindcss/defaultTheme");
2+
3+
module.exports = {
4+
mode: "jit",
5+
content: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
6+
darkMode: "class", // or 'media' or 'class'
7+
theme: {
8+
backgroundImage: {
9+
"panel-bg": "url('public/img/icons/panel-bg.png')",
10+
},
11+
container: {
12+
center: true,
13+
},
14+
fontFamily: {
15+
sans: ["Inter var", ...defaultTheme.fontFamily.sans],
16+
mono: ["'Major\\ Mono\\ Display'", ...defaultTheme.fontFamily.mono],
17+
},
18+
extend: {
19+
fontFamily: {
20+
display: ["Raleway", ...defaultTheme.fontFamily.sans],
21+
},
22+
colors: {
23+
primary: {
24+
darkest: "#3b5bdb",
25+
dark: "#4263eb",
26+
DEFAULT: "#5c7cfa",
27+
light: "#91a7ff",
28+
lightest: "#dbe4ff",
29+
},
30+
info: {
31+
darkest: "#1971c2",
32+
dark: "#1c7ed6",
33+
DEFAULT: "#339af0",
34+
light: "#74c0fc",
35+
lightest: "#d0ebff",
36+
},
37+
success: {
38+
darkest: "#099268",
39+
dark: "#0ca678",
40+
DEFAULT: "#20c997",
41+
light: "#63e6be",
42+
lightest: "#c3fae8",
43+
},
44+
error: {
45+
darkest: "#e03131",
46+
dark: "#f03e3e",
47+
DEFAULT: "#ff6b6b",
48+
light: "#ffa8a8",
49+
lightest: "#ffe3e3",
50+
},
51+
warning: {
52+
darkest: "#f08c00",
53+
dark: "#f59f00",
54+
DEFAULT: "#ff922b",
55+
light: "#ffe066",
56+
lightest: "#fff3bf",
57+
},
58+
},
59+
gridTemplateRows: {
60+
7: "repeat(7, minmax(0,1fr))",
61+
8: "repeat(8, minmax(0,1fr))",
62+
9: "repeat(9, minmax(0,1fr))",
63+
10: "repeat(10, minmax(0,1fr))",
64+
},
65+
},
66+
},
67+
};

0 commit comments

Comments
 (0)