@@ -38,7 +38,7 @@ class CardPlugin {
38
38
stage : Compilation . PROCESS_ASSETS_STAGE_ADDITIONAL
39
39
} ,
40
40
( ) => {
41
- let { pathSrc } = this . options
41
+ let { pathSrc, isCardMinVersion } = this . options
42
42
pathSrc = pathSrc . replace ( / \\ / g, '/' )
43
43
const moduleGraph = compilation . moduleGraph
44
44
for ( const chunk of compilation . chunks ) {
@@ -52,7 +52,7 @@ class CardPlugin {
52
52
request ,
53
53
pathSrc
54
54
)
55
- const templateRes = {
55
+ let templateRes = {
56
56
[ CARD_ENTRY ] : { }
57
57
}
58
58
const styleRes = { }
@@ -65,16 +65,20 @@ class CardPlugin {
65
65
pathSrc ,
66
66
bundleFilePath
67
67
)
68
- let handledTemplateCardRes
68
+
69
69
if ( this . isLiteCard ( entryRawRequest ) ) {
70
- handledTemplateCardRes = postHandleLiteCardRes ( templateRes )
70
+ templateRes = postHandleLiteCardRes ( templateRes )
71
+ } else if ( isCardMinVersion ) {
72
+ // 快应用 2.0 标准的 JS 卡,输出 .template.json 和 .css.json
73
+ templateRes = postHandleJSCardRes ( templateRes )
71
74
} else {
72
- handledTemplateCardRes = postHandleJSCardRes ( templateRes )
75
+ // 非快应用 2.0 标准的 JS 卡,不输出 .template.json 和 .css.json
76
+ continue
73
77
}
74
78
75
79
// 用于修改 template 的 key 的 stringify 的顺序,type 放第一个,children 放最后一个
76
80
let templateKeys = [ ]
77
- recordKeys ( handledTemplateCardRes , templateKeys )
81
+ recordKeys ( templateRes , templateKeys )
78
82
79
83
templateKeys = [ ...new Set ( templateKeys . sort ( ) ) ]
80
84
. filter (
@@ -85,15 +89,15 @@ class CardPlugin {
85
89
templateKeys . unshift ( 'type' , 'template' , 'data' )
86
90
87
91
// 自定义组件 template 抽取成独立 JSON —— 卡片不采用该方式
88
- // Object.keys(handledTemplateCardRes ).forEach((key) => {
89
- // const res = handledTemplateCardRes [key]
92
+ // Object.keys(templateRes ).forEach((key) => {
93
+ // const res = templateRes [key]
90
94
// const fileName = key === CARD_ENTRY ? templateFileName : `${key}.template.json`
91
95
// const templateJsonStr = JSON.stringify(res, templateKeys)
92
96
// compilation.assets[fileName] = new ConcatSource(templateJsonStr)
93
97
// })
94
98
95
99
// 处理 template
96
- const templateJsonStr = JSON . stringify ( handledTemplateCardRes , templateKeys )
100
+ const templateJsonStr = JSON . stringify ( templateRes , templateKeys )
97
101
compilation . assets [ templateFileName ] = new ConcatSource ( templateJsonStr )
98
102
99
103
// 处理 css
0 commit comments