create-vite-taro 0.5.16 → 0.6.0
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/package.json +1 -1
- package/templates/default/README.md +1 -1
- package/templates/default/_env.local +1 -1
- package/templates/default/package.json +6 -6
- package/templates/default/src/components/navigation-bar/use-navigation-bar.ts +1 -1
- package/templates/default/src/global.d.ts +1 -1
- package/templates/default/vite.config.ts +6 -6
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ npm run dev:h5
|
|
|
24
24
|
|
|
25
25
|
You can keep `npm run dev:wx` and `npm run dev:h5` running at the same time in separate terminals.
|
|
26
26
|
|
|
27
|
-
Set `
|
|
27
|
+
Set `VITE_VPT_WECHAT_APP_ID` in `.env.local` to your WeChat App ID, then open `dist/wx` with WeChat DevTools
|
|
28
28
|
for Mini Program development. State-preserving hot reload requires `compileHotReLoad: true`; the generated project sets
|
|
29
29
|
it automatically and also disables Skyline rendering and URL checks by default.
|
|
30
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
VITE_VPT_WECHAT_APP_ID=wx0000000000000000
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"version": "0.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev:wx": "cross-env NODE_ENV=development
|
|
8
|
-
"dev:h5": "cross-env NODE_ENV=development
|
|
9
|
-
"build:wx": "cross-env NODE_ENV=production
|
|
10
|
-
"build:h5": "cross-env NODE_ENV=production
|
|
11
|
-
"preview:h5": "cross-env NODE_ENV=production
|
|
7
|
+
"dev:wx": "cross-env NODE_ENV=development VITE_VPT_TARGET=wx vite",
|
|
8
|
+
"dev:h5": "cross-env NODE_ENV=development VITE_VPT_TARGET=h5 vite",
|
|
9
|
+
"build:wx": "cross-env NODE_ENV=production VITE_VPT_TARGET=wx vite build",
|
|
10
|
+
"build:h5": "cross-env NODE_ENV=production VITE_VPT_TARGET=h5 vite build",
|
|
11
|
+
"preview:h5": "cross-env NODE_ENV=production VITE_VPT_TARGET=h5 vite preview --outDir dist/h5",
|
|
12
12
|
"typecheck": "tsc -b"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"cross-env": "^10.1.0",
|
|
24
24
|
"rolldown": "1.2.3",
|
|
25
25
|
"vite": "8.2.1",
|
|
26
|
-
"vite-plugin-taro": "^0.
|
|
26
|
+
"vite-plugin-taro": "^0.6.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Taro from 'virtual:taro/api'
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
|
|
4
|
-
const isWechatTarget = import.meta.env.
|
|
4
|
+
const isWechatTarget = import.meta.env.VITE_VPT_TARGET === 'wx'
|
|
5
5
|
|
|
6
6
|
interface NavigationBarNavInfo {
|
|
7
7
|
height: number
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { fileURLToPath } from 'node:url'
|
|
3
3
|
import { defineConfig, loadEnv } from 'vite'
|
|
4
|
-
import
|
|
4
|
+
import vpt, { type VptTarget } from 'vite-plugin-taro'
|
|
5
5
|
|
|
6
|
-
const targetEnvName = '
|
|
6
|
+
const targetEnvName = 'VITE_VPT_TARGET'
|
|
7
7
|
const projectRoot = fileURLToPath(new URL('.', import.meta.url))
|
|
8
8
|
|
|
9
|
-
function getTarget(env: Record<string, string>):
|
|
9
|
+
function getTarget(env: Record<string, string>): VptTarget {
|
|
10
10
|
const target = env[targetEnvName]
|
|
11
11
|
if (target === 'wx' || target === 'h5') return target
|
|
12
12
|
throw new Error(`${targetEnvName} must be "wx" or "h5".`)
|
|
@@ -17,16 +17,16 @@ function fromRoot(...segments: string[]): string {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default defineConfig(({ mode }) => {
|
|
20
|
-
const env = loadEnv(mode, process.cwd(), '
|
|
20
|
+
const env = loadEnv(mode, process.cwd(), 'VITE_VPT_')
|
|
21
21
|
const target = getTarget(env)
|
|
22
|
-
const wechatAppId = env.
|
|
22
|
+
const wechatAppId = env.VITE_VPT_WECHAT_APP_ID || 'touristappid'
|
|
23
23
|
|
|
24
24
|
return {
|
|
25
25
|
build: {
|
|
26
26
|
outDir: fromRoot('dist', target)
|
|
27
27
|
},
|
|
28
28
|
plugins: [
|
|
29
|
-
|
|
29
|
+
vpt({
|
|
30
30
|
target,
|
|
31
31
|
app: 'src/app.tsx',
|
|
32
32
|
pages: [
|