forked from originjs/vite-plugin-federation
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add env variable demo (originjs#127)
- Loading branch information
Showing
21 changed files
with
342 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,7 +104,7 @@ dist | |
.tern-port | ||
|
||
.idea | ||
|
||
.DS_Store | ||
package-lock.json | ||
|
||
launch.json | ||
|
2 changes: 2 additions & 0 deletions
2
packages/examples/vue3-advanced-demo/router-host/.env.development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NODE_ENV=development | ||
VITE_APP_TITLE=My App (development) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NODE_ENV=production | ||
VITE_APP_TITLE=My App (pro) |
2 changes: 2 additions & 0 deletions
2
packages/examples/vue3-advanced-demo/router-host/.env.staging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NODE_ENV=production | ||
VITE_APP_TITLE=My App (staging) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 47 additions & 34 deletions
81
packages/examples/vue3-advanced-demo/router-host/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,52 @@ | ||
import {defineConfig} from "vite"; | ||
import { defineConfig, loadEnv } from "vite"; | ||
import vue from "@vitejs/plugin-vue"; | ||
import federation from "@originjs/vite-plugin-federation"; | ||
|
||
import { createHtmlPlugin } from 'vite-plugin-html' | ||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
vue(), | ||
federation({ | ||
name: "router-host", | ||
filename: "remoteEntry.js", | ||
remotes: { | ||
"router-remote": "http://localhost:5005/assets/remoteEntry.js", | ||
}, | ||
shared: ["vue", "vue-router", "element-plus", "vuex"] | ||
}) | ||
], | ||
// optimizeDeps:{ | ||
// include: ["element-plus"] | ||
// }, | ||
export default defineConfig(({ mode }) => { | ||
const root = process.cwd() | ||
|
||
const env = loadEnv(mode, root) | ||
return { | ||
plugins: [ | ||
vue(), | ||
federation({ | ||
name: "router-host", | ||
filename: "remoteEntry.js", | ||
remotes: { | ||
"router-remote": "http://localhost:5105/assets/remoteEntry.js", | ||
}, | ||
shared: ["vue", "vue-router", "element-plus", "vuex"] | ||
}), | ||
createHtmlPlugin({ | ||
inject: { | ||
// Inject data into ejs template | ||
data: { | ||
title: env.VITE_APP_TITLE, | ||
}, | ||
}, | ||
}), | ||
], | ||
// optimizeDeps:{ | ||
// include: ["element-plus"] | ||
// }, | ||
|
||
// 解决 const Home = {template: '<p>Home</p>'} 类组件无法在 vue-router 中显示的问题 | ||
resolve:{ | ||
alias:{ | ||
vue : 'vue/dist/vue.esm-bundler.js', | ||
'vue-router': 'vue-router/dist/vue-router.esm-bundler.js' | ||
} | ||
}, | ||
build: { | ||
target: 'esnext', | ||
minify: false, | ||
cssCodeSplit: true, | ||
rollupOptions: { | ||
output: { | ||
minifyInternalExports: false | ||
// 解决 const Home = {template: '<p>Home</p>'} 类组件无法在 vue-router 中显示的问题 | ||
resolve: { | ||
alias: { | ||
vue: 'vue/dist/vue.esm-bundler.js', | ||
'vue-router': 'vue-router/dist/vue-router.esm-bundler.js' | ||
} | ||
}, | ||
build: { | ||
target: 'esnext', | ||
minify: false, | ||
cssCodeSplit: true, | ||
rollupOptions: { | ||
output: { | ||
minifyInternalExports: false | ||
} | ||
} | ||
} | ||
}, | ||
}); | ||
}, | ||
} | ||
}) |
2 changes: 2 additions & 0 deletions
2
packages/examples/vue3-advanced-demo/router-remote/.env.development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NODE_ENV=development | ||
VITE_APP_TITLE=My App (development) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NODE_ENV=production | ||
VITE_APP_TITLE=My App (pro) |
2 changes: 2 additions & 0 deletions
2
packages/examples/vue3-advanced-demo/router-remote/.env.staging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NODE_ENV=production | ||
VITE_APP_TITLE=My App (staging) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/examples/vue3-advanced-demo/router-remote/public/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,8 @@ export default { | |
// } | ||
} | ||
</script> | ||
<style scoped> | ||
.el-button { | ||
color: red; | ||
} | ||
</style> |
96 changes: 60 additions & 36 deletions
96
packages/examples/vue3-advanced-demo/router-remote/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/examples/vue3-demo-webpack-esm-var/layout/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/examples/vue3-demo-webpack-systemjs/layout/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.