Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze config.ts in Egret

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report