mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-19 18:36:25 +00:00
Re-organize javascript files
This commit is contained in:
parent
ce59daeb24
commit
cb3017d533
10 changed files with 32 additions and 27 deletions
|
@ -1,4 +1,15 @@
|
|||
(async function() {
|
||||
const scripts = [
|
||||
"emulator.js",
|
||||
"nipplejs.js",
|
||||
"shaders.js",
|
||||
"storage.js",
|
||||
"gamepad.js",
|
||||
"GameManager.js",
|
||||
"socket.io.min.js"
|
||||
];
|
||||
|
||||
|
||||
const folderPath = (path) => path.substring(0, path.length - path.split('/').pop().length);
|
||||
let scriptPath = (typeof window.EJS_pathtodata === "string") ? window.EJS_pathtodata : folderPath((new URL(document.currentScript.src)).pathname);
|
||||
if (!scriptPath.endsWith('/')) scriptPath+='/';
|
||||
|
@ -9,8 +20,10 @@
|
|||
script.src = function() {
|
||||
if ('undefined' != typeof EJS_paths && typeof EJS_paths[file] === 'string') {
|
||||
return EJS_paths[file];
|
||||
} else if (file.endsWith(".min.js")) {
|
||||
return scriptPath + file;
|
||||
} else {
|
||||
return scriptPath+file;
|
||||
return scriptPath + "src/" + file;
|
||||
}
|
||||
}();
|
||||
script.onload = resolve;
|
||||
|
@ -46,13 +59,9 @@
|
|||
if (minifiedFailed) {
|
||||
console.log("Attempting to load non-minified files");
|
||||
if (file === "emulator.min.js") {
|
||||
await loadScript('emulator.js');
|
||||
await loadScript('nipplejs.js');
|
||||
await loadScript('shaders.js');
|
||||
await loadScript('storage.js');
|
||||
await loadScript('gamepad.js');
|
||||
await loadScript('GameManager.js');
|
||||
await loadScript('socket.io.min.js');
|
||||
for (let i=0; i<scripts.length; i++) {
|
||||
await loadScript(scripts[i]);
|
||||
}
|
||||
} else {
|
||||
await loadStyle('emulator.css');
|
||||
}
|
||||
|
@ -60,13 +69,9 @@
|
|||
}
|
||||
|
||||
if (('undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX)) {
|
||||
await loadScript('emulator.js');
|
||||
await loadScript('nipplejs.js');
|
||||
await loadScript('shaders.js');
|
||||
await loadScript('storage.js');
|
||||
await loadScript('gamepad.js');
|
||||
await loadScript('GameManager.js');
|
||||
await loadScript('socket.io.min.js');
|
||||
for (let i=0; i<scripts.length; i++) {
|
||||
await loadScript(scripts[i]);
|
||||
}
|
||||
await loadStyle('emulator.css');
|
||||
} else {
|
||||
await loadScript('emulator.min.js');
|
||||
|
|
|
@ -2,18 +2,18 @@ const UglifyJS = require("uglify-js");
|
|||
const fs = require('fs');
|
||||
const uglifycss = require('uglifycss');
|
||||
|
||||
let files = [
|
||||
'nipplejs.js',
|
||||
'shaders.js',
|
||||
'storage.js',
|
||||
'gamepad.js',
|
||||
'GameManager.js',
|
||||
'socket.io.min.js',
|
||||
'emulator.js'
|
||||
]
|
||||
const scripts = [
|
||||
"emulator.js",
|
||||
"nipplejs.js",
|
||||
"shaders.js",
|
||||
"storage.js",
|
||||
"gamepad.js",
|
||||
"GameManager.js",
|
||||
"socket.io.min.js"
|
||||
];
|
||||
let code = "(function() {\n";
|
||||
for (let i=0; i<files.length; i++) {
|
||||
code += fs.readFileSync('../'+files[i], 'utf8') + "\n";
|
||||
for (let i=0; i<scripts.length; i++) {
|
||||
code += fs.readFileSync('../src/'+scripts[i], 'utf8') + "\n";
|
||||
}
|
||||
code += "\n})();"
|
||||
|
||||
|
|
Loading…
Reference in a new issue