From c13aad4d1d5e3fbb24a03793a142cf22e6a7ec26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=87?= Date: Wed, 11 Sep 2019 11:17:15 +0800 Subject: [PATCH] upgrade 5.2.28 --- agora/demo/egretProperties.json | 4 +- agora/demo/scripts/api.d.ts | 4 ++ agora/demo/scripts/config.vivogame.ts | 7 ++- agora/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- benchmark/demo/egretProperties.json | 4 +- benchmark/demo/scripts/api.d.ts | 4 ++ benchmark/demo/scripts/config.vivogame.ts | 7 ++- benchmark/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- dcagent/demo/egretProperties.json | 4 +- dcagent/demo/scripts/api.d.ts | 4 ++ dcagent/demo/scripts/config.vivogame.ts | 7 ++- dcagent/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- ecs/demo/egretProperties.json | 4 +- ecs/demo/scripts/api.d.ts | 4 ++ ecs/demo/scripts/config.vivogame.ts | 7 ++- ecs/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- .../ComboBox/demo/egretProperties.json | 4 +- euiextension/ComboBox/demo/scripts/api.d.ts | 4 ++ .../ComboBox/demo/scripts/config.vivogame.ts | 7 ++- .../demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- .../TreeView/demo/egretProperties.json | 4 +- euiextension/TreeView/demo/scripts/api.d.ts | 4 ++ .../TreeView/demo/scripts/config.vivogame.ts | 7 ++- .../demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- gesture/demo/egretProperties.json | 4 +- gesture/demo/scripts/api.d.ts | 4 ++ gesture/demo/scripts/config.vivogame.ts | 7 ++- gesture/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- greensock/demo/egretProperties.json | 4 +- greensock/demo/scripts/api.d.ts | 4 ++ greensock/demo/scripts/config.vivogame.ts | 7 ++- greensock/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- jszip/demo/egretProperties.json | 4 +- jszip/demo/scripts/api.d.ts | 4 ++ jszip/demo/scripts/config.vivogame.ts | 7 ++- jszip/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- keyboard/demo/egretProperties.json | 4 +- keyboard/demo/scripts/api.d.ts | 4 ++ keyboard/demo/scripts/config.vivogame.ts | 7 ++- keyboard/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- matchvs/demo/egretProperties.json | 4 +- matchvs/demo/scripts/api.d.ts | 4 ++ matchvs/demo/scripts/config.vivogame.ts | 7 ++- matchvs/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- md5/demo/egretProperties.json | 4 +- md5/demo/scripts/api.d.ts | 4 ++ md5/demo/scripts/config.vivogame.ts | 7 ++- md5/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- mouse/demo/egretProperties.json | 4 +- mouse/demo/scripts/api.d.ts | 4 ++ mouse/demo/scripts/config.vivogame.ts | 7 ++- mouse/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- particle/demo/egretProperties.json | 4 +- particle/demo/scripts/api.d.ts | 4 ++ particle/demo/scripts/config.vivogame.ts | 7 ++- particle/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- physics/demo/egretProperties.json | 4 +- physics/demo/scripts/api.d.ts | 4 ++ physics/demo/scripts/config.vivogame.ts | 7 ++- physics/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- physics/demo2/egretProperties.json | 4 +- physics/demo2/scripts/api.d.ts | 4 ++ physics/demo2/scripts/config.vivogame.ts | 7 ++- physics/demo2/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- physics/featuresDemo/egretProperties.json | 4 +- physics/featuresDemo/scripts/api.d.ts | 4 ++ .../featuresDemo/scripts/config.vivogame.ts | 7 ++- .../featuresDemo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- socket.io/demo/egretProperties.json | 4 +- socket.io/demo/scripts/api.d.ts | 4 ++ socket.io/demo/scripts/config.vivogame.ts | 7 ++- socket.io/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- tiled/demo/egretProperties.json | 4 +- tiled/demo/scripts/api.d.ts | 4 ++ tiled/demo/scripts/config.vivogame.ts | 7 ++- tiled/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- weixinapi/demo/egretProperties.json | 4 +- weixinapi/demo/scripts/api.d.ts | 4 ++ weixinapi/demo/scripts/config.vivogame.ts | 7 ++- weixinapi/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- youmeim/demo/egretProperties.json | 4 +- youmeim/demo/scripts/api.d.ts | 4 ++ youmeim/demo/scripts/config.vivogame.ts | 7 ++- youmeim/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- youmertc/demo/egretProperties.json | 4 +- youmertc/demo/scripts/api.d.ts | 4 ++ youmertc/demo/scripts/config.vivogame.ts | 7 ++- youmertc/demo/scripts/vivogame/vivogame.ts | 48 ++++++++++++------- 88 files changed, 924 insertions(+), 462 deletions(-) diff --git a/agora/demo/egretProperties.json b/agora/demo/egretProperties.json index 732394db..ae8d96c6 100644 --- a/agora/demo/egretProperties.json +++ b/agora/demo/egretProperties.json @@ -1,6 +1,6 @@ { - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27", + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28", "template": {}, "target": { "current": "web" diff --git a/agora/demo/scripts/api.d.ts b/agora/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/agora/demo/scripts/api.d.ts +++ b/agora/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/agora/demo/scripts/config.vivogame.ts b/agora/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/agora/demo/scripts/config.vivogame.ts +++ b/agora/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/agora/demo/scripts/vivogame/vivogame.ts b/agora/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/agora/demo/scripts/vivogame/vivogame.ts +++ b/agora/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/benchmark/demo/egretProperties.json b/benchmark/demo/egretProperties.json index 1ef07eb2..10d04961 100644 --- a/benchmark/demo/egretProperties.json +++ b/benchmark/demo/egretProperties.json @@ -29,6 +29,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/benchmark/demo/scripts/api.d.ts b/benchmark/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/benchmark/demo/scripts/api.d.ts +++ b/benchmark/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/benchmark/demo/scripts/config.vivogame.ts b/benchmark/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/benchmark/demo/scripts/config.vivogame.ts +++ b/benchmark/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/benchmark/demo/scripts/vivogame/vivogame.ts b/benchmark/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/benchmark/demo/scripts/vivogame/vivogame.ts +++ b/benchmark/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/dcagent/demo/egretProperties.json b/dcagent/demo/egretProperties.json index 4b709d5f..4846d1b5 100644 --- a/dcagent/demo/egretProperties.json +++ b/dcagent/demo/egretProperties.json @@ -30,6 +30,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/dcagent/demo/scripts/api.d.ts b/dcagent/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/dcagent/demo/scripts/api.d.ts +++ b/dcagent/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/dcagent/demo/scripts/config.vivogame.ts b/dcagent/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/dcagent/demo/scripts/config.vivogame.ts +++ b/dcagent/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/dcagent/demo/scripts/vivogame/vivogame.ts b/dcagent/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/dcagent/demo/scripts/vivogame/vivogame.ts +++ b/dcagent/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/ecs/demo/egretProperties.json b/ecs/demo/egretProperties.json index 25c71a4d..86ff217e 100644 --- a/ecs/demo/egretProperties.json +++ b/ecs/demo/egretProperties.json @@ -30,6 +30,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/ecs/demo/scripts/api.d.ts b/ecs/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/ecs/demo/scripts/api.d.ts +++ b/ecs/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/ecs/demo/scripts/config.vivogame.ts b/ecs/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/ecs/demo/scripts/config.vivogame.ts +++ b/ecs/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/ecs/demo/scripts/vivogame/vivogame.ts b/ecs/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/ecs/demo/scripts/vivogame/vivogame.ts +++ b/ecs/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/euiextension/ComboBox/demo/egretProperties.json b/euiextension/ComboBox/demo/egretProperties.json index a358ba35..641ad22f 100644 --- a/euiextension/ComboBox/demo/egretProperties.json +++ b/euiextension/ComboBox/demo/egretProperties.json @@ -30,6 +30,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/euiextension/ComboBox/demo/scripts/api.d.ts b/euiextension/ComboBox/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/euiextension/ComboBox/demo/scripts/api.d.ts +++ b/euiextension/ComboBox/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/euiextension/ComboBox/demo/scripts/config.vivogame.ts b/euiextension/ComboBox/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/euiextension/ComboBox/demo/scripts/config.vivogame.ts +++ b/euiextension/ComboBox/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/euiextension/ComboBox/demo/scripts/vivogame/vivogame.ts b/euiextension/ComboBox/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/euiextension/ComboBox/demo/scripts/vivogame/vivogame.ts +++ b/euiextension/ComboBox/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/euiextension/TreeView/demo/egretProperties.json b/euiextension/TreeView/demo/egretProperties.json index 5f29b2ab..9ce1079a 100644 --- a/euiextension/TreeView/demo/egretProperties.json +++ b/euiextension/TreeView/demo/egretProperties.json @@ -30,6 +30,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/euiextension/TreeView/demo/scripts/api.d.ts b/euiextension/TreeView/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/euiextension/TreeView/demo/scripts/api.d.ts +++ b/euiextension/TreeView/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/euiextension/TreeView/demo/scripts/config.vivogame.ts b/euiextension/TreeView/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/euiextension/TreeView/demo/scripts/config.vivogame.ts +++ b/euiextension/TreeView/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/euiextension/TreeView/demo/scripts/vivogame/vivogame.ts b/euiextension/TreeView/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/euiextension/TreeView/demo/scripts/vivogame/vivogame.ts +++ b/euiextension/TreeView/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/gesture/demo/egretProperties.json b/gesture/demo/egretProperties.json index 1d8aaeab..b439cb8d 100644 --- a/gesture/demo/egretProperties.json +++ b/gesture/demo/egretProperties.json @@ -29,6 +29,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/gesture/demo/scripts/api.d.ts b/gesture/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/gesture/demo/scripts/api.d.ts +++ b/gesture/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/gesture/demo/scripts/config.vivogame.ts b/gesture/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/gesture/demo/scripts/config.vivogame.ts +++ b/gesture/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/gesture/demo/scripts/vivogame/vivogame.ts b/gesture/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/gesture/demo/scripts/vivogame/vivogame.ts +++ b/gesture/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/greensock/demo/egretProperties.json b/greensock/demo/egretProperties.json index e25475c9..055f4775 100644 --- a/greensock/demo/egretProperties.json +++ b/greensock/demo/egretProperties.json @@ -29,6 +29,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/greensock/demo/scripts/api.d.ts b/greensock/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/greensock/demo/scripts/api.d.ts +++ b/greensock/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/greensock/demo/scripts/config.vivogame.ts b/greensock/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/greensock/demo/scripts/config.vivogame.ts +++ b/greensock/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/greensock/demo/scripts/vivogame/vivogame.ts b/greensock/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/greensock/demo/scripts/vivogame/vivogame.ts +++ b/greensock/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/jszip/demo/egretProperties.json b/jszip/demo/egretProperties.json index c2dab326..fafd53fe 100644 --- a/jszip/demo/egretProperties.json +++ b/jszip/demo/egretProperties.json @@ -30,6 +30,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/jszip/demo/scripts/api.d.ts b/jszip/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/jszip/demo/scripts/api.d.ts +++ b/jszip/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/jszip/demo/scripts/config.vivogame.ts b/jszip/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/jszip/demo/scripts/config.vivogame.ts +++ b/jszip/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/jszip/demo/scripts/vivogame/vivogame.ts b/jszip/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/jszip/demo/scripts/vivogame/vivogame.ts +++ b/jszip/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/keyboard/demo/egretProperties.json b/keyboard/demo/egretProperties.json index fec003f0..a9fcd0a6 100644 --- a/keyboard/demo/egretProperties.json +++ b/keyboard/demo/egretProperties.json @@ -18,6 +18,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/keyboard/demo/scripts/api.d.ts b/keyboard/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/keyboard/demo/scripts/api.d.ts +++ b/keyboard/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/keyboard/demo/scripts/config.vivogame.ts b/keyboard/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/keyboard/demo/scripts/config.vivogame.ts +++ b/keyboard/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/keyboard/demo/scripts/vivogame/vivogame.ts b/keyboard/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/keyboard/demo/scripts/vivogame/vivogame.ts +++ b/keyboard/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/matchvs/demo/egretProperties.json b/matchvs/demo/egretProperties.json index f4b5af62..ba04fc8a 100644 --- a/matchvs/demo/egretProperties.json +++ b/matchvs/demo/egretProperties.json @@ -1,6 +1,6 @@ { - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27", + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28", "template": {}, "target": { "current": "web" diff --git a/matchvs/demo/scripts/api.d.ts b/matchvs/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/matchvs/demo/scripts/api.d.ts +++ b/matchvs/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/matchvs/demo/scripts/config.vivogame.ts b/matchvs/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/matchvs/demo/scripts/config.vivogame.ts +++ b/matchvs/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/matchvs/demo/scripts/vivogame/vivogame.ts b/matchvs/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/matchvs/demo/scripts/vivogame/vivogame.ts +++ b/matchvs/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/md5/demo/egretProperties.json b/md5/demo/egretProperties.json index cc2da0bc..b5c74193 100644 --- a/md5/demo/egretProperties.json +++ b/md5/demo/egretProperties.json @@ -25,6 +25,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/md5/demo/scripts/api.d.ts b/md5/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/md5/demo/scripts/api.d.ts +++ b/md5/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/md5/demo/scripts/config.vivogame.ts b/md5/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/md5/demo/scripts/config.vivogame.ts +++ b/md5/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/md5/demo/scripts/vivogame/vivogame.ts b/md5/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/md5/demo/scripts/vivogame/vivogame.ts +++ b/md5/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/mouse/demo/egretProperties.json b/mouse/demo/egretProperties.json index f2fe611c..0ce77912 100644 --- a/mouse/demo/egretProperties.json +++ b/mouse/demo/egretProperties.json @@ -21,6 +21,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/mouse/demo/scripts/api.d.ts b/mouse/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/mouse/demo/scripts/api.d.ts +++ b/mouse/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/mouse/demo/scripts/config.vivogame.ts b/mouse/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/mouse/demo/scripts/config.vivogame.ts +++ b/mouse/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/mouse/demo/scripts/vivogame/vivogame.ts b/mouse/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/mouse/demo/scripts/vivogame/vivogame.ts +++ b/mouse/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/particle/demo/egretProperties.json b/particle/demo/egretProperties.json index 22d766a9..8e430069 100644 --- a/particle/demo/egretProperties.json +++ b/particle/demo/egretProperties.json @@ -21,6 +21,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/particle/demo/scripts/api.d.ts b/particle/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/particle/demo/scripts/api.d.ts +++ b/particle/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/particle/demo/scripts/config.vivogame.ts b/particle/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/particle/demo/scripts/config.vivogame.ts +++ b/particle/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/particle/demo/scripts/vivogame/vivogame.ts b/particle/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/particle/demo/scripts/vivogame/vivogame.ts +++ b/particle/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/physics/demo/egretProperties.json b/physics/demo/egretProperties.json index faed3baf..decc02fa 100644 --- a/physics/demo/egretProperties.json +++ b/physics/demo/egretProperties.json @@ -25,6 +25,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/physics/demo/scripts/api.d.ts b/physics/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/physics/demo/scripts/api.d.ts +++ b/physics/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/physics/demo/scripts/config.vivogame.ts b/physics/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/physics/demo/scripts/config.vivogame.ts +++ b/physics/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/physics/demo/scripts/vivogame/vivogame.ts b/physics/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/physics/demo/scripts/vivogame/vivogame.ts +++ b/physics/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/physics/demo2/egretProperties.json b/physics/demo2/egretProperties.json index 554d5e91..c46f7c24 100644 --- a/physics/demo2/egretProperties.json +++ b/physics/demo2/egretProperties.json @@ -30,6 +30,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/physics/demo2/scripts/api.d.ts b/physics/demo2/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/physics/demo2/scripts/api.d.ts +++ b/physics/demo2/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/physics/demo2/scripts/config.vivogame.ts b/physics/demo2/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/physics/demo2/scripts/config.vivogame.ts +++ b/physics/demo2/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/physics/demo2/scripts/vivogame/vivogame.ts b/physics/demo2/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/physics/demo2/scripts/vivogame/vivogame.ts +++ b/physics/demo2/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/physics/featuresDemo/egretProperties.json b/physics/featuresDemo/egretProperties.json index 554d5e91..c46f7c24 100644 --- a/physics/featuresDemo/egretProperties.json +++ b/physics/featuresDemo/egretProperties.json @@ -30,6 +30,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/physics/featuresDemo/scripts/api.d.ts b/physics/featuresDemo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/physics/featuresDemo/scripts/api.d.ts +++ b/physics/featuresDemo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/physics/featuresDemo/scripts/config.vivogame.ts b/physics/featuresDemo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/physics/featuresDemo/scripts/config.vivogame.ts +++ b/physics/featuresDemo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/physics/featuresDemo/scripts/vivogame/vivogame.ts b/physics/featuresDemo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/physics/featuresDemo/scripts/vivogame/vivogame.ts +++ b/physics/featuresDemo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/socket.io/demo/egretProperties.json b/socket.io/demo/egretProperties.json index f549d73f..c1602677 100644 --- a/socket.io/demo/egretProperties.json +++ b/socket.io/demo/egretProperties.json @@ -25,6 +25,6 @@ "path": "${EGRET_DEFAULT}" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/socket.io/demo/scripts/api.d.ts b/socket.io/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/socket.io/demo/scripts/api.d.ts +++ b/socket.io/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/socket.io/demo/scripts/config.vivogame.ts b/socket.io/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/socket.io/demo/scripts/config.vivogame.ts +++ b/socket.io/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/socket.io/demo/scripts/vivogame/vivogame.ts b/socket.io/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/socket.io/demo/scripts/vivogame/vivogame.ts +++ b/socket.io/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/tiled/demo/egretProperties.json b/tiled/demo/egretProperties.json index 243baa2f..0ebbf200 100644 --- a/tiled/demo/egretProperties.json +++ b/tiled/demo/egretProperties.json @@ -26,6 +26,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/tiled/demo/scripts/api.d.ts b/tiled/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/tiled/demo/scripts/api.d.ts +++ b/tiled/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/tiled/demo/scripts/config.vivogame.ts b/tiled/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/tiled/demo/scripts/config.vivogame.ts +++ b/tiled/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/tiled/demo/scripts/vivogame/vivogame.ts b/tiled/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/tiled/demo/scripts/vivogame/vivogame.ts +++ b/tiled/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/weixinapi/demo/egretProperties.json b/weixinapi/demo/egretProperties.json index 4a94788b..4f74ca4a 100644 --- a/weixinapi/demo/egretProperties.json +++ b/weixinapi/demo/egretProperties.json @@ -21,6 +21,6 @@ "path": "../libsrc" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/weixinapi/demo/scripts/api.d.ts b/weixinapi/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/weixinapi/demo/scripts/api.d.ts +++ b/weixinapi/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/weixinapi/demo/scripts/config.vivogame.ts b/weixinapi/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/weixinapi/demo/scripts/config.vivogame.ts +++ b/weixinapi/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/weixinapi/demo/scripts/vivogame/vivogame.ts b/weixinapi/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/weixinapi/demo/scripts/vivogame/vivogame.ts +++ b/weixinapi/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/youmeim/demo/egretProperties.json b/youmeim/demo/egretProperties.json index 059c18a8..dbc2a094 100644 --- a/youmeim/demo/egretProperties.json +++ b/youmeim/demo/egretProperties.json @@ -49,6 +49,6 @@ "path": "../libsrc/yimamr" } ], - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27" + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28" } \ No newline at end of file diff --git a/youmeim/demo/scripts/api.d.ts b/youmeim/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/youmeim/demo/scripts/api.d.ts +++ b/youmeim/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/youmeim/demo/scripts/config.vivogame.ts b/youmeim/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/youmeim/demo/scripts/config.vivogame.ts +++ b/youmeim/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/youmeim/demo/scripts/vivogame/vivogame.ts b/youmeim/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/youmeim/demo/scripts/vivogame/vivogame.ts +++ b/youmeim/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } } diff --git a/youmertc/demo/egretProperties.json b/youmertc/demo/egretProperties.json index a2b20af9..3208d2d2 100644 --- a/youmertc/demo/egretProperties.json +++ b/youmertc/demo/egretProperties.json @@ -1,6 +1,6 @@ { - "engineVersion": "5.2.27", - "compilerVersion": "5.2.27", + "engineVersion": "5.2.28", + "compilerVersion": "5.2.28", "template": {}, "target": { "current": "web" diff --git a/youmertc/demo/scripts/api.d.ts b/youmertc/demo/scripts/api.d.ts index 63fdf187..8428bc40 100644 --- a/youmertc/demo/scripts/api.d.ts +++ b/youmertc/demo/scripts/api.d.ts @@ -287,6 +287,10 @@ declare module 'built-in' { * 其他传递的消息参数 */ info?:any + /** + * use wechat engine plugin + */ + useWxPlugin?: boolean } /** diff --git a/youmertc/demo/scripts/config.vivogame.ts b/youmertc/demo/scripts/config.vivogame.ts index 54abd053..dbcfb5ca 100644 --- a/youmertc/demo/scripts/config.vivogame.ts +++ b/youmertc/demo/scripts/config.vivogame.ts @@ -16,7 +16,7 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "debug", defines: { DEBUG: true, RELEASE: false } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), @@ -28,11 +28,14 @@ const config: ResourceManagerConfig = { return { outputDir, commands: [ - new CleanPlugin({ matchers: ["../engine", "resource"] }), + new CleanPlugin({ matchers: ["../engine/js", "resource"] }), new CompilePlugin({ libraryType: "release", defines: { DEBUG: false, RELEASE: true } }), new ExmlPlugin('commonjs'), // 非 EUI 项目关闭此设置 new VivogamePlugin(), new UglifyPlugin([{ + sources: ["resource/default.thm.js"], + target: "default.thm.min.js" + }, { sources: ["main.js"], target: "main.min.js" } diff --git a/youmertc/demo/scripts/vivogame/vivogame.ts b/youmertc/demo/scripts/vivogame/vivogame.ts index 9fe3460a..84756dd1 100644 --- a/youmertc/demo/scripts/vivogame/vivogame.ts +++ b/youmertc/demo/scripts/vivogame/vivogame.ts @@ -7,10 +7,11 @@ export class VivogamePlugin implements plugins.Command { async onFile(file: plugins.File) { if (file.extname == '.js') { const filename = file.origin; - this.jsFileList.push(file.basename) + if (filename == "libs/modules/promise/promise.js" || filename == 'libs/modules/promise/promise.min.js') { return null; } + this.jsFileList.push(file.basename) if (filename == 'libs/modules/egret/egret.js' || filename == 'libs/modules/egret/egret.min.js') { let content = file.contents.toString(); content += `;window.egret = egret;`; @@ -86,27 +87,40 @@ export class VivogamePlugin implements plugins.Command { const gameJSONPath = path.join(pluginContext.outputDir, "manifest.json"); let gameJSONContent = JSON.parse(fs.readFileSync(gameJSONPath, { encoding: "utf8" })); gameJSONContent.deviceOrientation = orientation; + let engineVersion = this.readData(path.join(pluginContext.projectRoot, "egretProperties.json")).engineVersion + if(!gameJSONContent.thirdEngine)gameJSONContent.thirdEngine={} + gameJSONContent.thirdEngine.egret = engineVersion + fs.writeFileSync(gameJSONPath, JSON.stringify(gameJSONContent, null, "\t")); let isPublish = pluginContext.buildConfig.command == "publish" ? true : false; - let configOption = "webpackConf.externals = Object.assign(webpackConf.externals || {\n\t\t" + let configArr: any[] = [] for (var i = 0, len = this.jsFileList.length; i < len; i++) { let jsFile = this.jsFileList[i]; - if(isPublish && jsFile == "main.js"){ - jsFile = 'main.min.js' - } - configOption += `"js/${jsFile}":"commonjs js/${jsFile}"` - if (i < len - 1) { - configOption += ",\n\t\t" - } else { - configOption += "\n\t\t" + if (isPublish) { + if (jsFile == "main.js") { + jsFile = 'main.min.js' + } else if (jsFile == "default.thm.js") { + jsFile = "default.thm.min.js" + } } + configArr.push(JSON.stringify({ + module_name: `./js/${jsFile}`, + module_path: `./js/${jsFile}`, + module_from: `engine/js/${jsFile}`, + }, null, "\t")) } - configOption += "})" - const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configOption + '\n\t\t\/\/----auto option end----'; - - const webpackConfigPath = path.join(pluginContext.outputDir, '../config', "webpack.config.js"); - let configJSContent = fs.readFileSync(webpackConfigPath, { encoding: "utf8" }); - configJSContent = configJSContent.replace(reg, replaceConfigStr); - fs.writeFileSync(webpackConfigPath, configJSContent); + const replaceConfigStr = '\/\/----auto option start----\n\t\t' + configArr.toString() + '\n\t\t\/\/----auto option end----'; + const minigameConfigPath = path.join(pluginContext.outputDir,"../", "minigame.config.js"); + if(!fs.existsSync(minigameConfigPath)){ + //5.2.28版本,vivo更新了项目结构,老项目需要升级 + fs.writeFileSync(path.join(pluginContext.outputDir,"../","vivo更新了项目结构,请重新创建vivo小游戏项目.js"), "vivo更新了项目结构,请重新创建vivo小游戏项目"); + }else{ + let configJSContent = fs.readFileSync(minigameConfigPath, { encoding: "utf8" }); + configJSContent = configJSContent.replace(reg, replaceConfigStr); + fs.writeFileSync(minigameConfigPath, configJSContent); + } + } + readData(filePath: string): any { + return JSON.parse(fs.readFileSync(filePath, { encoding: "utf8" })); } }