@@ -38,7 +38,7 @@ class CardPlugin {
3838 stage : Compilation . PROCESS_ASSETS_STAGE_ADDITIONAL
3939 } ,
4040 ( ) => {
41- let { pathSrc } = this . options
41+ let { pathSrc, isCardMinVersion } = this . options
4242 pathSrc = pathSrc . replace ( / \\ / g, '/' )
4343 const moduleGraph = compilation . moduleGraph
4444 for ( const chunk of compilation . chunks ) {
@@ -52,7 +52,7 @@ class CardPlugin {
5252 request ,
5353 pathSrc
5454 )
55- const templateRes = {
55+ let templateRes = {
5656 [ CARD_ENTRY ] : { }
5757 }
5858 const styleRes = { }
@@ -65,16 +65,20 @@ class CardPlugin {
6565 pathSrc ,
6666 bundleFilePath
6767 )
68- let handledTemplateCardRes
68+
6969 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 )
7174 } else {
72- handledTemplateCardRes = postHandleJSCardRes ( templateRes )
75+ // 非快应用 2.0 标准的 JS 卡,不输出 .template.json 和 .css.json
76+ continue
7377 }
7478
7579 // 用于修改 template 的 key 的 stringify 的顺序,type 放第一个,children 放最后一个
7680 let templateKeys = [ ]
77- recordKeys ( handledTemplateCardRes , templateKeys )
81+ recordKeys ( templateRes , templateKeys )
7882
7983 templateKeys = [ ...new Set ( templateKeys . sort ( ) ) ]
8084 . filter (
@@ -85,15 +89,15 @@ class CardPlugin {
8589 templateKeys . unshift ( 'type' , 'template' , 'data' )
8690
8791 // 自定义组件 template 抽取成独立 JSON —— 卡片不采用该方式
88- // Object.keys(handledTemplateCardRes ).forEach((key) => {
89- // const res = handledTemplateCardRes [key]
92+ // Object.keys(templateRes ).forEach((key) => {
93+ // const res = templateRes [key]
9094 // const fileName = key === CARD_ENTRY ? templateFileName : `${key}.template.json`
9195 // const templateJsonStr = JSON.stringify(res, templateKeys)
9296 // compilation.assets[fileName] = new ConcatSource(templateJsonStr)
9397 // })
9498
9599 // 处理 template
96- const templateJsonStr = JSON . stringify ( handledTemplateCardRes , templateKeys )
100+ const templateJsonStr = JSON . stringify ( templateRes , templateKeys )
97101 compilation . assets [ templateFileName ] = new ConcatSource ( templateJsonStr )
98102
99103 // 处理 css
0 commit comments