vite-plugin-taro 0.3.0 → 0.3.1
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/dist/node/build-context.d.ts +1 -1
- package/dist/node/targets/wx/companion-assets.d.ts +1 -0
- package/dist/node/targets/wx/companion-assets.js +9 -1
- package/dist/options.d.ts +1 -1
- package/package.json +3 -3
- package/src/node/build-context.ts +1 -1
- package/src/node/targets/wx/companion-assets.ts +12 -2
- package/src/options.ts +1 -1
|
@@ -7,7 +7,7 @@ type ProjectContext = Readonly<{
|
|
|
7
7
|
pages: readonly VitePluginTaroPageOption[];
|
|
8
8
|
appConfig: JsonObject;
|
|
9
9
|
projectConfigJson: JsonObject;
|
|
10
|
-
projectPrivateConfigJson
|
|
10
|
+
projectPrivateConfigJson?: JsonObject;
|
|
11
11
|
sitemapJson: JsonObject;
|
|
12
12
|
}>;
|
|
13
13
|
/** Owns the shared project, Vite lifecycle state, and cross-target services for one build. */
|
|
@@ -7,6 +7,12 @@ const taroWxComponentsPath = packageRequire.resolve('@tarojs/plugin-platform-wea
|
|
|
7
7
|
const templateBuilder = createWxTemplateBuilder();
|
|
8
8
|
export function emitWxCompanionAssets(emitter, bundle, context) {
|
|
9
9
|
for (const asset of createWxCompanionAssets(bundle, context)) {
|
|
10
|
+
if (!asset)
|
|
11
|
+
continue;
|
|
12
|
+
if (asset.source === undefined) {
|
|
13
|
+
emitter.warn(`[vite-plugin-taro] WX companion asset "${asset.fileName}" is missing its source and was not emitted.`);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
10
16
|
emitter.emitFile({ type: 'asset', fileName: asset.fileName, source: asset.source });
|
|
11
17
|
}
|
|
12
18
|
}
|
|
@@ -23,7 +29,9 @@ function createWxCompanionAssets(bundle, context) {
|
|
|
23
29
|
{ fileName: 'comp.wxml', source: templateBuilder.buildBaseComponentTemplate('.wxml') },
|
|
24
30
|
{ fileName: 'comp.json', source: json(createWxComponentConfig()) },
|
|
25
31
|
{ fileName: 'project.config.json', source: json(createWxProjectConfig(context)) },
|
|
26
|
-
|
|
32
|
+
context.project.projectPrivateConfigJson
|
|
33
|
+
? { fileName: 'project.private.config.json', source: json(context.project.projectPrivateConfigJson) }
|
|
34
|
+
: undefined,
|
|
27
35
|
{ fileName: 'sitemap.json', source: json(context.project.sitemapJson) },
|
|
28
36
|
...context.project.pages.flatMap((page) => [
|
|
29
37
|
{
|
package/dist/options.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-taro",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"react-refresh": "^0.18.0",
|
|
67
67
|
"tailwindcss": "^4.3.2",
|
|
68
68
|
"weapp-tailwindcss": "^5.1.14",
|
|
69
|
-
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.3.
|
|
70
|
-
"@tarojs/react": "npm:vite-plugin-taro-react@0.3.
|
|
69
|
+
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@0.3.1",
|
|
70
|
+
"@tarojs/react": "npm:vite-plugin-taro-react@0.3.1"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"react": "^19.0.0",
|
|
@@ -19,6 +19,7 @@ export type WxBundle = Record<
|
|
|
19
19
|
|
|
20
20
|
type WxAssetEmitter = {
|
|
21
21
|
emitFile(asset: { type: 'asset'; fileName: string; source: WxAssetSource }): string
|
|
22
|
+
warn(message: string): void
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
type WxTemplateComponentConfig = {
|
|
@@ -33,6 +34,13 @@ const templateBuilder = createWxTemplateBuilder()
|
|
|
33
34
|
|
|
34
35
|
export function emitWxCompanionAssets(emitter: WxAssetEmitter, bundle: WxBundle, context: BuildContext): void {
|
|
35
36
|
for (const asset of createWxCompanionAssets(bundle, context)) {
|
|
37
|
+
if (!asset) continue
|
|
38
|
+
if (asset.source === undefined) {
|
|
39
|
+
emitter.warn(
|
|
40
|
+
`[vite-plugin-taro] WX companion asset "${asset.fileName}" is missing its source and was not emitted.`
|
|
41
|
+
)
|
|
42
|
+
continue
|
|
43
|
+
}
|
|
36
44
|
emitter.emitFile({ type: 'asset', fileName: asset.fileName, source: asset.source })
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -40,7 +48,7 @@ export function emitWxCompanionAssets(emitter: WxAssetEmitter, bundle: WxBundle,
|
|
|
40
48
|
function createWxCompanionAssets(
|
|
41
49
|
bundle: WxBundle,
|
|
42
50
|
context: BuildContext
|
|
43
|
-
): { fileName: string; source: WxAssetSource }[] {
|
|
51
|
+
): ({ fileName: string; source: WxAssetSource } | undefined)[] {
|
|
44
52
|
const json = (value: JsonObject) => (context.development ? JSON.stringify(value, null, 2) : JSON.stringify(value))
|
|
45
53
|
|
|
46
54
|
return [
|
|
@@ -54,7 +62,9 @@ function createWxCompanionAssets(
|
|
|
54
62
|
{ fileName: 'comp.wxml', source: templateBuilder.buildBaseComponentTemplate('.wxml') },
|
|
55
63
|
{ fileName: 'comp.json', source: json(createWxComponentConfig()) },
|
|
56
64
|
{ fileName: 'project.config.json', source: json(createWxProjectConfig(context)) },
|
|
57
|
-
|
|
65
|
+
context.project.projectPrivateConfigJson
|
|
66
|
+
? { fileName: 'project.private.config.json', source: json(context.project.projectPrivateConfigJson) }
|
|
67
|
+
: undefined,
|
|
58
68
|
{ fileName: 'sitemap.json', source: json(context.project.sitemapJson) },
|
|
59
69
|
...context.project.pages.flatMap((page) => [
|
|
60
70
|
{
|
package/src/options.ts
CHANGED