@playcraft/devkit 1.0.29 → 1.0.30

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.
@@ -8,7 +8,7 @@
8
8
  data.html=data.html.replace(/<meta\s+charset=["'][^"']*["']\s*\/?>/i,"<meta charset=\"utf-8\" />");// viewport: Mintegral 需要 minimum-scale,其他渠道通用
9
9
  const viewportContent=this.adNetwork==="mintegral"?META.MINTEGRAL_VIEWPORT:META.COMMON_VIEWPORT;data.html=data.html.replace(/<meta\s+name=["']viewport["'][^>]*\/?>/i,`<meta name="viewport" content="${viewportContent}" />`);// font-family: Liftoff 渠道需要指定系统字体
10
10
  if(this.adNetwork==="liftoff"){const fontStyle=FontFamily.LIFTOFF;data.html=data.html.replace("</head>",fontStyle+"</head>")}return data})})}}/** @type {AD_NETWORK[]} *//** @type {AD_NETWORK[]} */const zipOutputNetworks=["google","pangle","tiktok","vungle","mytarget","mintegral","adikteev","bigabid","inmobi",// InMobi 支持 ZIP 格式(包含 index.html + 资源文件)
11
- "snapchat","bigoads","liftoff","facebook",// Facebook 默认 ZIP,包体上限 5MB
11
+ "snapchat","bigoads","liftoff","facebook",// Facebook:ZIP 内仅 index.html(JS 全部内联),上限 5MB
12
12
  "remerge"// Remerge Rich Media:ZIP + index.html + mraid.js
13
13
  ];/** @type {AD_NETWORK[]} */const zipOutputAllowedNetworks=["moloco"];/**
14
14
  * Creates webpack configuration for production build
@@ -56,12 +56,13 @@ if(adNetwork==="adikteev"){const cssRuleIndex=webpackConfig.module.rules.findInd
56
56
  // - mintegral: 需要独立的 JS 文件
57
57
  // - adikteev: 需要 creative.js 上传到 CDN
58
58
  // - bigabid: 需要 main.js 上传到 CDN
59
- // - facebook: ZIP 格式(index.html + build.js,包体上限 5MB)
60
- if(adNetwork!=="mintegral"&&adNetwork!=="adikteev"&&adNetwork!=="bigabid"&&!(isZipOutputFinal&&adNetwork==="facebook"))webpackConfig.plugins.push(new HtmlInlineScriptPlugin);// 注入渠道 SDK 插件(公共逻辑)
59
+ // Facebook ZIP 只要单文件 index.html,JS 必须内联
60
+ if(adNetwork!=="mintegral"&&adNetwork!=="adikteev"&&adNetwork!=="bigabid")webpackConfig.plugins.push(new HtmlInlineScriptPlugin);// 注入渠道 SDK 插件(公共逻辑)
61
61
  injectSDKPlugins(webpackConfig,{network:adNetwork,protocol:adProtocol,playcraftOrientationValue});if(isZipOutputFinal){if(adNetwork==="tiktok"){webpackConfig.plugins.push(new CopyWebpackPlugin({patterns:[{from:path.join(__dirname,"resources","tiktok-config.json"),to:"config.json"}]}))}else if(adNetwork==="snapchat"){const tmpConfigPath=path.join(__dirname,"resources","snapchat-config.json");webpackConfig.plugins.push(new CopyWebpackPlugin({patterns:[{from:tmpConfigPath,to:"config.json"}]}))}else if(adNetwork==="bigoads"){// BigoAds 要求输出 ZIP 包,包含 index.html 和 config.json
62
62
  // SDK 注入已在 injectSDKPlugins 中处理
63
- webpackConfig.plugins.push(new CopyWebpackPlugin({patterns:[{from:path.join(__dirname,"resources","bigoads-config.json"),to:"config.json"}]}))}webpackConfig.plugins.push(new ZipPlugin({filename:isChannelFold2Zip?outputId:getFileName(),path:path.resolve(outDir),cleanTempFolder:true// 🗑️ 生成 zip 后删除临时文件夹
64
- }));webpackConfig.output.path=path.resolve(outDir,outputId);if(adNetwork==="adikteev"){webpackConfig.output.filename="creative.js";// Adikteev 需要将 CSS 单独提取为 style.css 文件
63
+ webpackConfig.plugins.push(new CopyWebpackPlugin({patterns:[{from:path.join(__dirname,"resources","bigoads-config.json"),to:"config.json"}]}))}webpackConfig.plugins.push(new ZipPlugin({filename:isChannelFold2Zip?outputId:getFileName(),path:path.resolve(outDir),cleanTempFolder:true,// 🗑️ 生成 zip 后删除临时文件夹
64
+ // Facebook:zip 内只保留内联后的 index.html,不要带上 build.js
65
+ ...(adNetwork==="facebook"?{include:/(?:^|\/)index\.html$/}:{})}));webpackConfig.output.path=path.resolve(outDir,outputId);if(adNetwork==="adikteev"){webpackConfig.output.filename="creative.js";// Adikteev 需要将 CSS 单独提取为 style.css 文件
65
66
  webpackConfig.plugins.push(new MiniCssExtractPlugin({filename:"style.css"}))}else if(adNetwork==="bigabid")webpackConfig.output.filename="main.js";else if(adNetwork==="inmobi")webpackConfig.output.filename="main.js"}// 添加 fflate 压缩插件(仅在打正式包时生效)
66
67
  if(buildOptions.fflateCompression){console.log("\u2705 fflate compression enabled (production build only)");webpackConfig.plugins.push(new FflateCompressionPlugin({enabled:true,level:9,keepOriginal:false,logStats:true,googlePlayUrl:buildOptions.googlePlayUrl,appStoreUrl:buildOptions.appStoreUrl}))}return webpackConfig}/**
67
68
  * Runs webpack production build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@playcraft/devkit",
3
- "version": "1.0.29",
4
- "description": "HTML5 Playable Ads \u6784\u5efa\u5de5\u5177\uff0c\u652f\u6301\u591a\u5e7f\u544a\u6e20\u9053\u6253\u5305",
3
+ "version": "1.0.30",
4
+ "description": "HTML5 Playable Ads 构建工具,支持多广告渠道打包",
5
5
  "main": "core/index.js",
6
6
  "module": "core/index.js",
7
7
  "types": "core/index.d.ts",
@@ -82,4 +82,4 @@
82
82
  "publishConfig": {
83
83
  "registry": "https://registry.npmjs.org/"
84
84
  }
85
- }
85
+ }