Skip to content

Commit 47647dd

Browse files
committed
feat: vue demo
1 parent d2cd8ae commit 47647dd

File tree

12 files changed

+57
-48
lines changed

12 files changed

+57
-48
lines changed

packages/demo-child-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"preview": "vite preview"
88
},
99
"dependencies": {
10-
"@micro-web/sub": "^0.2.0",
10+
"@micro-web/sub": "^0.2.1",
1111
"history": "^5.2.0",
1212
"react": "^17.0.2",
1313
"react-dom": "^17.0.2",

packages/demo-child-react/src/App.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import React from "react";
1+
import React from 'react';
22
import {
33
unstable_HistoryRouter as HistoryRouter,
44
Link,
55
Route,
66
Routes,
7-
} from "react-router-dom";
8-
import { BrowserHistory, createBrowserHistory } from "history";
9-
import Example from "./pages/example";
10-
import Foo from "./pages/foo";
11-
import styles from "./App.module.less";
7+
} from 'react-router-dom';
8+
import { BrowserHistory, createBrowserHistory } from 'history';
9+
import Example from './pages/example';
10+
import Foo from './pages/foo';
11+
import styles from './App.module.less';
1212

1313
export interface AppProps {
1414
history?: BrowserHistory;
@@ -18,9 +18,9 @@ const currentHistory = createBrowserHistory();
1818

1919
function App({ history = currentHistory }: AppProps) {
2020
React.useEffect(() => {
21-
console.log("[mount] - React child");
21+
console.log('[mount] - React child');
2222
return () => {
23-
console.log("[unmount] - React child");
23+
console.log('[unmount] - React child');
2424
};
2525
}, []);
2626

packages/demo-child-vue/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
</head>
99
<body>
1010
<div id="app"></div>
11-
<script type="module" src="/src/main.ts"></script>
11+
<script type="module" src="/src/main.tsx"></script>
1212
</body>
1313
</html>

packages/demo-child-vue/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"version": "0.0.0",
44
"scripts": {
55
"dev": "vite",
6-
"build": "vue-tsc --noEmit && vite build",
6+
"build": "vite build",
77
"preview": "vite preview"
88
},
99
"dependencies": {
10+
"@micro-web/sub": "^0.2.1",
1011
"vue": "^3.2.25"
1112
},
1213
"devDependencies": {
14+
"@micro-web/vite-plugin": "^0.2.0",
1315
"@vitejs/plugin-vue": "^2.0.0",
1416
"vite": "^2.7.2",
1517
"vue-tsc": "^0.29.8"

packages/demo-child-vue/src/App.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import HelloWorld from "./components/HelloWorld.vue";
66
import logo from "./assets/logo.png";
77
88
const msg = ref("Hello Vue 3 + TypeScript + Vite");
9-
const logoURL = new URL(logo, import.meta.url);
109
</script>
1110

1211
<template>
13-
<img class="vue-logo" alt="Vue logo" :src="logoURL.href" />
12+
<img class="vue-logo" alt="Vue logo" :src="logo" />
1413
<HelloWorld :msg="msg" />
1514
</template>
1615

packages/demo-child-vue/src/main.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

packages/demo-child-vue/src/main.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { createApp } from 'vue';
2+
import { defineMicroApp } from '@micro-web/sub';
3+
import App from './App.vue';
4+
5+
if (!import.meta.url.includes('microAppEnv')) {
6+
createApp(App).mount('#app');
7+
}
8+
9+
export default defineMicroApp((container: HTMLElement) => {
10+
const app = createApp(App);
11+
return {
12+
mount() {
13+
app.mount(container);
14+
},
15+
unmount() {
16+
app.unmount();
17+
},
18+
};
19+
});

packages/demo-child-vue/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"useDefineForClassFields": true,
55
"module": "esnext",
66
"moduleResolution": "node",
7+
"allowJs": false,
8+
"skipLibCheck": true,
79
"strict": true,
810
"jsx": "preserve",
911
"sourceMap": true,
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { defineConfig } from "vite";
2-
import vue from "@vitejs/plugin-vue";
1+
import { defineConfig } from 'vite';
2+
import vue from '@vitejs/plugin-vue';
3+
import { microWebPlugin } from '@micro-web/vite-plugin';
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
6-
base: "/vue/",
7+
base: '/vue/',
78
server: {
89
port: 3004,
910
},
10-
plugins: [vue()],
11+
plugins: [vue(), microWebPlugin()],
1112
});

packages/demo-react/src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
unstable_HistoryRouter as HistoryRouter,
33
Link,
4-
} from "react-router-dom";
5-
import Pages from "./pages";
6-
import { history } from "./common/history";
7-
import logo from "./logo.svg";
8-
import styles from "./App.module.less";
4+
} from 'react-router-dom';
5+
import Pages from './pages';
6+
import { history } from './common/history';
7+
import logo from './logo.svg';
8+
import styles from './App.module.less';
99

1010
function App() {
1111
return (

packages/demo-react/src/pages/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default function Pages() {
2626
<MicroApp
2727
key="vue"
2828
className="micro-app"
29-
entry="//localhost:3004/vue/src/main.ts"
29+
entry="//localhost:3004/vue/src/main.tsx"
30+
// entry="//localhost:5000/vue/main.js"
3031
fallback="加载中"
3132
history={history}
3233
/>

pnpm-lock.yaml

Lines changed: 10 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)