From 42da95a8e424dac85c13aa37c24425fb54aec101 Mon Sep 17 00:00:00 2001 From: sh-winter <2943331588@qq.com> Date: Sat, 16 Jul 2022 19:34:07 +0800 Subject: [PATCH] release: v2.0.0 --- README.md | 41 +++++++++++++++++++++++++++++------------ package.json | 8 ++++---- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 252df61..1baae14 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,28 @@ -### 简介 +# vite-plugin-qiankun -> 简化 `vite` 子应用接入 `qiankun` 的流程 -### 快速开始 +简化 `vite` 子应用接入 `qiankun` 的流程 + +## 要求 + +此包适用于 vite 2.6+ ,不包含 vite 3.0。 + +## 安装 + +使用 `npm`: + +```console +$ npm install @sh-winter/vite-plugin-qiankun --save-dev +``` + + + +## 用法 + +### 1. 注册插件 -#### 1. 安装 `vite` 插件 ```ts // vite.config.ts - import qiankun from '@sh-winter/vite-plugin-qiankun' import { name as packageName } from './package.json' @@ -19,10 +34,10 @@ export default { } ``` -#### 2. 导出 `qiankun` 生命周期钩子 +### 2. 子应用导出 `qiankun` 生命周期钩子 + ```ts // main.ts - import { exportLifeCycleHooks, qiankunWindow } from '@sh-winter/vite-plugin-qiankun/dist/helper' // some code @@ -49,14 +64,16 @@ if (!qiankunWindow.__POWERED_BY_QIANKUN__) { } ``` -#### 3. 注意事项 +### 3. 注意事项 1. `es module` 会导致 `qiankun` 沙箱失效,如果想要访问 `qiankun` 提供的代理 `window`,请使用 `qiankunWindow` + ```ts - import { qiankunWindow } from '@sh-winter/vite-plugin-qiankun/dist/helper' +import { qiankunWindow } from '@sh-winter/vite-plugin-qiankun/dist/helper' ``` 2. 如果是 `vue` 子应用,开发环境下需要额外引入 `vue-template-compiler transform` 插件:`transformAssetUrl` + ```ts // vite.config.ts @@ -77,8 +94,8 @@ if (!qiankunWindow.__POWERED_BY_QIANKUN__) { } ``` -### 查看示例 +## 查看示例 ```bash -yarn example -``` +npm run example +``` \ No newline at end of file diff --git a/package.json b/package.json index cbeb4f3..2613b41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sh-winter/vite-plugin-qiankun", - "version": "0.1.1", + "version": "2.0.0", "description": "vite qiankun plugin", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -30,7 +30,7 @@ "cheerio": "^1.0.0-rc.10", "srcset": "4.0.0", "valid-data-url": "^4.0.0", - "vite": ">=2" + "vite": "^2.9.9" }, "devDependencies": { "@rollup/plugin-typescript": "^8.3.0", @@ -50,7 +50,7 @@ "typescript": "^4.5.5" }, "peerDependencies": { - "@vue/compiler-sfc": ">=3", - "vite": ">=2" + "@vue/compiler-sfc": ">=3.2.0", + "vite": ">=2.6.0" } }