How to analyze config.ts in Egret
This article is about how to analyze config.ts in Egret. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
One: preface
The config in the project is actually related to build / publish, as follows
①, config.ts are related to web platform
②, config.wxgame.ts are related to wxgame
Now I will only explain the file compression method of publish in config.ts.
Second: file compression (mainly egret class library)
In the command = = 'publish' module
Const outputDir = `bin-release/web/$ {version} ` Return {outputDir, commands: [new CustomPlugin (), new CompilePlugin ({libraryType: "release", defines: {DEBUG: false, RELEASE: true}}), new ExmlPlugin ('commonjs') / / close this setting contents new UglifyPlugin for non-EUI projects ([{/ / files to be compressed sources: ["libs/modules/egret/egret.min.js") "libs/modules/egret/egret.web.min.js", "libs/modules/res/res.min.js", "libs/modules/tween/tween.min.js", "libs/modules/game/game.min.js" "libs/modules/promise/promise.min.js", "libs/modules/eui/eui.min.js", "libs/modules/socket/socket.min.js" "libs/modules/jszip/jszip.min.js"], / / compressed file target: "lib.main.min.js"} {sources: ["main.js"], target: "main.min.js"}]), new RenamePlugin ({verbose: true, hash: 'crc32' Matchers: [{from: "* * / * .js", to: "[path] [name] _ [hash]. [ext]"} / / hash]}), / / new ResPlugin () New ManifestPlugin ({output: "manifest.json"})]}
To compress the JS file, you need to use the UplifyPlugin plug-in, as shown in the above code (figure below)
Three: benefits
① reduces the number of requests
② hides class library code
The above is how to analyze the config.ts in Egret. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.