vite-plugin-taro 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +19 -19
- package/README.md +19 -19
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -28,11 +28,11 @@ Use `create-vite-taro` for new apps. It generates a Vite 8 + React 19 + Taro pro
|
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
30
|
# Create a new app from the default template
|
|
31
|
-
|
|
31
|
+
npm create vite-taro@latest my-app
|
|
32
32
|
|
|
33
33
|
# Enter the project and install dependencies
|
|
34
34
|
cd my-app
|
|
35
|
-
|
|
35
|
+
npm install
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### 2. Configure WeChat App ID
|
|
@@ -43,18 +43,18 @@ The template creates `.env.local`. Set `VITE_PLUGIN_TARO_WECHAT_APP_ID` to your
|
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
45
|
# WeChat Mini Program: rebuild dist/wx in watch mode
|
|
46
|
-
|
|
46
|
+
npm run dev:wx
|
|
47
47
|
|
|
48
48
|
# Then open dist/wx in WeChat DevTools
|
|
49
49
|
|
|
50
50
|
# H5: start the Vite dev server
|
|
51
|
-
|
|
51
|
+
npm run dev:h5
|
|
52
52
|
|
|
53
53
|
# Then open the standard Vite dev URL in your browser
|
|
54
54
|
# http://localhost:5173
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
You can keep `
|
|
57
|
+
You can keep `npm run dev:wx` and `npm run dev:h5` running at the same time in separate terminals.
|
|
58
58
|
|
|
59
59
|
Note: Because of WeChat DevTools and Mini Program runtime limitations, hot reload/fast rebuilds for the WeChat target may not always apply cleanly. For day-to-day iteration, prefer the H5 Vite dev server for fast feedback, and periodically verify the Mini Program result in WeChat DevTools.
|
|
60
60
|
|
|
@@ -62,16 +62,16 @@ Note: Because of WeChat DevTools and Mini Program runtime limitations, hot reloa
|
|
|
62
62
|
|
|
63
63
|
```sh
|
|
64
64
|
# Production WeChat Mini Program output
|
|
65
|
-
|
|
65
|
+
npm run build:wx
|
|
66
66
|
|
|
67
67
|
# Production H5 output
|
|
68
|
-
|
|
68
|
+
npm run build:h5
|
|
69
69
|
|
|
70
70
|
# Preview the built H5 app
|
|
71
|
-
|
|
71
|
+
npm run preview:h5
|
|
72
72
|
|
|
73
73
|
# Typecheck with tsgo
|
|
74
|
-
|
|
74
|
+
npm run typecheck
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
For existing apps or custom project layouts, follow the manual setup below.
|
|
@@ -81,14 +81,14 @@ For existing apps or custom project layouts, follow the manual setup below.
|
|
|
81
81
|
For existing apps or custom project layouts, follow the steps below to wire the plugin manually. First, install the plugin:
|
|
82
82
|
|
|
83
83
|
```sh
|
|
84
|
-
|
|
84
|
+
npm install -D vite-plugin-taro
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
Your app must also provide Vite 8, React 19, React DOM 19, a TypeScript checker, and Node/React type packages. If your app does not already have them, install the missing packages:
|
|
88
88
|
|
|
89
89
|
```sh
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
npm install react react-dom
|
|
91
|
+
npm install -D vite @typescript/native-preview @types/node @types/react @types/react-dom
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
You should NOT have direct dependencies on `@tarojs/*` packages anymore. Remove them if you have.
|
|
@@ -287,12 +287,12 @@ On Windows shells, use `cross-env`.
|
|
|
287
287
|
### 7. Run each target
|
|
288
288
|
|
|
289
289
|
```sh
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
npm run dev:wx # Rebuild dist/wx in watch mode
|
|
291
|
+
npm run dev:h5 # Start the H5 dev server
|
|
292
|
+
npm run build:wx # Build dist/wx
|
|
293
|
+
npm run build:h5 # Build dist/h5
|
|
294
|
+
npm run preview:h5 # Preview dist/h5
|
|
295
|
+
npm run typecheck # Typecheck with tsgo
|
|
296
296
|
```
|
|
297
297
|
|
|
298
298
|
Open the generated `dist/wx` directory in WeChat DevTools.
|
|
@@ -499,7 +499,7 @@ Common scripts:
|
|
|
499
499
|
| Problem | Check |
|
|
500
500
|
| --- | --- |
|
|
501
501
|
| `VITE_PLUGIN_TARO_TARGET must be "wx" or "h5"` | Set the target environment variable in your script or `.env` file. |
|
|
502
|
-
| `pnpm install` says dependency build scripts were ignored | Run `pnpm approve-builds
|
|
502
|
+
| `pnpm install` says dependency build scripts were ignored | Run `pnpm approve-builds` and approve the requested dependency build scripts. |
|
|
503
503
|
| A page cannot be resolved | Confirm that `pages[].path` has a matching `src/${path}.tsx` file. |
|
|
504
504
|
| WeChat DevTools cannot open the app | Open the generated `dist/wx` folder and check `projectConfigJson.appid`. |
|
|
505
505
|
| H5 shows a blank page | Keep `<div id="app"></div>` in `index.html`, register the plugin, and avoid adding a separate default Vite `main.tsx` entry. |
|
package/README.md
CHANGED
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
30
|
# 使用默认模板创建新应用
|
|
31
|
-
|
|
31
|
+
npm create vite-taro@latest my-app
|
|
32
32
|
|
|
33
33
|
# 进入项目并安装依赖
|
|
34
34
|
cd my-app
|
|
35
|
-
|
|
35
|
+
npm install
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### 2. 配置微信 App ID
|
|
@@ -43,18 +43,18 @@ pnpm install
|
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
45
|
# 微信小程序:以 watch 模式重新构建 dist/wx
|
|
46
|
-
|
|
46
|
+
npm run dev:wx
|
|
47
47
|
|
|
48
48
|
# 然后在微信开发者工具中打开 dist/wx
|
|
49
49
|
|
|
50
50
|
# H5:启动 Vite 开发服务器
|
|
51
|
-
|
|
51
|
+
npm run dev:h5
|
|
52
52
|
|
|
53
53
|
# 然后在浏览器中打开标准 Vite 地址
|
|
54
54
|
# http://localhost:5173
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
你可以在两个终端中同时运行 `
|
|
57
|
+
你可以在两个终端中同时运行 `npm run dev:wx` 和 `npm run dev:h5`。
|
|
58
58
|
|
|
59
59
|
提示:受微信限制,开发者工具热重载有时不会完整生效。建议日常优先使用 H5 的 Vite 热更新快速调试,并定期在微信开发者工具中验证小程序端效果。
|
|
60
60
|
|
|
@@ -62,16 +62,16 @@ pnpm dev:h5
|
|
|
62
62
|
|
|
63
63
|
```sh
|
|
64
64
|
# 生产微信小程序产物
|
|
65
|
-
|
|
65
|
+
npm run build:wx
|
|
66
66
|
|
|
67
67
|
# 生产 H5 产物
|
|
68
|
-
|
|
68
|
+
npm run build:h5
|
|
69
69
|
|
|
70
70
|
# 预览构建后的 H5 应用
|
|
71
|
-
|
|
71
|
+
npm run preview:h5
|
|
72
72
|
|
|
73
73
|
# 使用 tsgo 进行类型检查
|
|
74
|
-
|
|
74
|
+
npm run typecheck
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
已有应用或自定义项目结构,请继续阅读下面的手动接入步骤。
|
|
@@ -81,14 +81,14 @@ pnpm typecheck
|
|
|
81
81
|
已有应用或自定义项目结构,可以按下面的步骤手动接入插件。先安装插件:
|
|
82
82
|
|
|
83
83
|
```sh
|
|
84
|
-
|
|
84
|
+
npm install -D vite-plugin-taro
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
你的应用还必须提供 Vite 8、React 19、React DOM 19、TypeScript 检查器,以及 Node/React 类型包。如果应用尚未安装它们,请安装缺失的包:
|
|
88
88
|
|
|
89
89
|
```sh
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
npm install react react-dom
|
|
91
|
+
npm install -D vite @typescript/native-preview @types/node @types/react @types/react-dom
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
你不应再直接依赖任何 `@tarojs/*` 包。如果已经依赖,请将它们移除。
|
|
@@ -287,12 +287,12 @@ export default function IndexPage() {
|
|
|
287
287
|
### 7. 运行每个目标
|
|
288
288
|
|
|
289
289
|
```sh
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
290
|
+
npm run dev:wx # 以 watch 模式重新构建 dist/wx
|
|
291
|
+
npm run dev:h5 # 启动 H5 开发服务器
|
|
292
|
+
npm run build:wx # 构建 dist/wx
|
|
293
|
+
npm run build:h5 # 构建 dist/h5
|
|
294
|
+
npm run preview:h5 # 预览 dist/h5
|
|
295
|
+
npm run typecheck # 使用 tsgo 进行类型检查
|
|
296
296
|
```
|
|
297
297
|
|
|
298
298
|
在微信开发者工具中打开生成的 `dist/wx` 目录。
|
|
@@ -499,7 +499,7 @@ pnpm typecheck
|
|
|
499
499
|
| 问题 | 检查项 |
|
|
500
500
|
| --- | --- |
|
|
501
501
|
| `VITE_PLUGIN_TARO_TARGET must be "wx" or "h5"` | 在脚本或 `.env` 文件中设置目标环境变量。 |
|
|
502
|
-
| `pnpm install` 提示忽略了依赖构建脚本 | 运行 `pnpm approve-builds
|
|
502
|
+
| `pnpm install` 提示忽略了依赖构建脚本 | 运行 `pnpm approve-builds`,按提示批准需要构建的依赖。 |
|
|
503
503
|
| 页面无法解析 | 确认 `pages[].path` 有匹配的 `src/${path}.tsx` 文件。 |
|
|
504
504
|
| 微信开发者工具无法打开应用 | 打开生成的 `dist/wx` 文件夹,并检查 `projectConfigJson.appid`。 |
|
|
505
505
|
| H5 显示空白页 | 确保 `index.html` 中保留 `<div id="app"></div>`,已注册插件,并避免添加单独的默认 Vite `main.tsx` 入口。 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"author": "sep2",
|
|
5
5
|
"description": "Vite 8 plugin for building one React/Taro codebase for WeChat Mini Program and H5 targets.",
|
|
6
6
|
"type": "module",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"babel-plugin-transform-taroapi": "^4.2.0",
|
|
65
65
|
"tailwindcss": "^4.3.1",
|
|
66
66
|
"weapp-tailwindcss": "^5.0.13",
|
|
67
|
-
"@tarojs/react": "npm:vite-plugin-taro-react@0.1.
|
|
68
|
-
"@tarojs/
|
|
67
|
+
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.1.3",
|
|
68
|
+
"@tarojs/react": "npm:vite-plugin-taro-react@0.1.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"react": "^19.0.0",
|