main.js压缩,类型

This commit is contained in:
unanmed 2023-02-28 18:21:29 +08:00
parent 023d913ea7
commit c7168ccfde
22 changed files with 47 additions and 2922 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -216,12 +216,14 @@ function main() {
this.__VERSION__ = '2.10.0'; this.__VERSION__ = '2.10.0';
this.__VERSION_CODE__ = 510; this.__VERSION_CODE__ = 510;
} }
// >>>> body end
main.prototype.init = function (mode, callback) { main.prototype.init = function (mode, callback) {
try { try {
var a = {}; var a = {};
var b = {}; var b = {};
new Proxy(a, b); new Proxy(a, b);
new Promise(res => res());
const aa = `${123}`; const aa = `${123}`;
aa; aa;
} catch (e) { } catch (e) {
@ -235,24 +237,12 @@ main.prototype.init = function (mode, callback) {
} }
main.mode = mode; main.mode = mode;
Promise.all();
main.loadJs('project', main.pureData, function () { main.loadJs('project', main.pureData, function () {
var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main; var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main;
for (var ii in mainData) main[ii] = mainData[ii]; for (var ii in mainData) main[ii] = mainData[ii];
// main.levelChoose = main.levelChoose || [];
// main.levelChoose.forEach(function (value) {
// var span = document.createElement('span');
// span.setAttribute('class', 'startButton');
// span.innerText = value.title || '';
// span.id = value.name;
// (function (span, str_) {
// span.onclick = function () {
// core.events.startGame(str_);
// };
// })(span, value.name || '');
// main.dom.levelChooseButtons.appendChild(span);
// });
main.importFonts(main.fonts); main.importFonts(main.fonts);
main.loadJs('libs', main.loadList, function () { main.loadJs('libs', main.loadList, function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
// 1000多行改不动了 // 1000多行改不动了

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -1,3 +1,4 @@
///<reference path="../../../src/types/core.d.ts" />
'use strict'; 'use strict';
(function () { (function () {

View File

@ -115,4 +115,29 @@ import { exec } from 'child_process';
} catch { } catch {
console.log('压缩插件失败'); console.log('压缩插件失败');
} }
// 4. 压缩main.js
try {
// 先获取不能压缩的部分
const main = await fs.readFile('./dist/main.js', 'utf-8');
const endIndex = main.indexOf('// >>>> body end');
const nonCompress = main.slice(0, endIndex);
const needCompress = main.slice(endIndex + 17);
await fs.writeFile('./dist/temp.js', needCompress, 'utf-8');
await fs.rm('./dist/main.js');
exec('babel ./dist/temp.js --out-file ./dist/main.js').on(
'close',
async () => {
const nowMain = await fs.readFile('./dist/main.js', 'utf-8');
await fs.writeFile(
'./dist/main.js',
nonCompress + nowMain,
'utf-8'
);
await fs.rm('./dist/temp.js');
}
);
} catch {
console.log('main.js压缩失败');
}
})(); })();