File tree 12 files changed +57
-48
lines changed
12 files changed +57
-48
lines changed Original file line number Diff line number Diff line change 7
7
"preview" : " vite preview"
8
8
},
9
9
"dependencies" : {
10
- "@micro-web/sub" : " ^0.2.0 " ,
10
+ "@micro-web/sub" : " ^0.2.1 " ,
11
11
"history" : " ^5.2.0" ,
12
12
"react" : " ^17.0.2" ,
13
13
"react-dom" : " ^17.0.2" ,
Original file line number Diff line number Diff line change 1
- import React from " react" ;
1
+ import React from ' react' ;
2
2
import {
3
3
unstable_HistoryRouter as HistoryRouter ,
4
4
Link ,
5
5
Route ,
6
6
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' ;
12
12
13
13
export interface AppProps {
14
14
history ?: BrowserHistory ;
@@ -18,9 +18,9 @@ const currentHistory = createBrowserHistory();
18
18
19
19
function App ( { history = currentHistory } : AppProps ) {
20
20
React . useEffect ( ( ) => {
21
- console . log ( " [mount] - React child" ) ;
21
+ console . log ( ' [mount] - React child' ) ;
22
22
return ( ) => {
23
- console . log ( " [unmount] - React child" ) ;
23
+ console . log ( ' [unmount] - React child' ) ;
24
24
} ;
25
25
} , [ ] ) ;
26
26
Original file line number Diff line number Diff line change 8
8
</ head >
9
9
< body >
10
10
< div id ="app "> </ div >
11
- < script type ="module " src ="/src/main.ts "> </ script >
11
+ < script type ="module " src ="/src/main.tsx "> </ script >
12
12
</ body >
13
13
</ html >
Original file line number Diff line number Diff line change 3
3
"version" : " 0.0.0" ,
4
4
"scripts" : {
5
5
"dev" : " vite" ,
6
- "build" : " vue-tsc --noEmit && vite build" ,
6
+ "build" : " vite build" ,
7
7
"preview" : " vite preview"
8
8
},
9
9
"dependencies" : {
10
+ "@micro-web/sub" : " ^0.2.1" ,
10
11
"vue" : " ^3.2.25"
11
12
},
12
13
"devDependencies" : {
14
+ "@micro-web/vite-plugin" : " ^0.2.0" ,
13
15
"@vitejs/plugin-vue" : " ^2.0.0" ,
14
16
"vite" : " ^2.7.2" ,
15
17
"vue-tsc" : " ^0.29.8"
Original file line number Diff line number Diff line change @@ -6,11 +6,10 @@ import HelloWorld from "./components/HelloWorld.vue";
6
6
import logo from " ./assets/logo.png" ;
7
7
8
8
const msg = ref (" Hello Vue 3 + TypeScript + Vite" );
9
- const logoURL = new URL (logo , import .meta .url );
10
9
</script >
11
10
12
11
<template >
13
- <img class =" vue-logo" alt =" Vue logo" :src =" logoURL.href " />
12
+ <img class =" vue-logo" alt =" Vue logo" :src =" logo " />
14
13
<HelloWorld :msg =" msg" />
15
14
</template >
16
15
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change 4
4
"useDefineForClassFields" : true ,
5
5
"module" : " esnext" ,
6
6
"moduleResolution" : " node" ,
7
+ "allowJs" : false ,
8
+ "skipLibCheck" : true ,
7
9
"strict" : true ,
8
10
"jsx" : " preserve" ,
9
11
"sourceMap" : true ,
Original file line number Diff line number Diff line change 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' ;
3
4
4
5
// https://vitejs.dev/config/
5
6
export default defineConfig ( {
6
- base : " /vue/" ,
7
+ base : ' /vue/' ,
7
8
server : {
8
9
port : 3004 ,
9
10
} ,
10
- plugins : [ vue ( ) ] ,
11
+ plugins : [ vue ( ) , microWebPlugin ( ) ] ,
11
12
} ) ;
Original file line number Diff line number Diff line change 1
1
import {
2
2
unstable_HistoryRouter as HistoryRouter ,
3
3
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' ;
9
9
10
10
function App ( ) {
11
11
return (
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ export default function Pages() {
26
26
< MicroApp
27
27
key = "vue"
28
28
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"
30
31
fallback = "加载中"
31
32
history = { history }
32
33
/>
You can’t perform that action at this time.
0 commit comments