Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: vite.md #406

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/zh-cn/framework/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default defineConfig({
(function () {
let basePath = ''
return {
name: "vite:micro-app",
// name即子应用的name值
name: "basename",
apply: 'build',
configResolved(config) {
basePath = `${config.base}${config.build.assetsDir}/`
Expand All @@ -51,6 +52,8 @@ export default defineConfig({
})
```

> **注意:** 子应用中 `name` 需与基座应用中 `name` 保持一致。

**2、修改容器元素id**

因为vite子应用没有元素隔离的保护,建议修改容器元素的id值,以确保与其它元素不冲突。
Expand Down Expand Up @@ -97,7 +100,8 @@ const router = createRouter({
**1、关闭沙箱并使用内联script模式**
```js
<micro-app
name='child-name'
// name即子应用 vite.config.js 中name值
name='basename'
url='http://localhost:3001/basename/'
inline // 使用内联script模式
disableSandbox // 关闭沙箱
Expand All @@ -114,8 +118,8 @@ import microApp from '@micro-zoe/micro-app'
microApp.start({
plugins: {
modules: {
// appName即应用的name值
appName: [{
// name即子应用 vite.config.js 中name值
name: [{
loader(code) {
if (process.env.NODE_ENV === 'development') {
// 这里 basename 需要和子应用vite.config.js中base的配置保持一致
Expand Down