@reactunity/scripts 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/react-unity-scripts.js +6 -1
- package/config/env.js +1 -3
- package/config/eslint/base.js +43 -0
- package/config/eslint/config.js +252 -0
- package/config/eslint/jest.js +59 -0
- package/config/eslintConfig.js +2 -17
- package/config/jest/babelTransform.js +37 -0
- package/config/jest/cssTransform.js +22 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/paths.js +6 -0
- package/config/unityMiddleware.js +29 -0
- package/config/web-inspector/Build/WebInspector.data +0 -0
- package/config/web-inspector/Build/WebInspector.framework.js +1 -1
- package/config/web-inspector/Build/WebInspector.loader.js +1 -1
- package/config/web-inspector/Build/WebInspector.wasm +0 -0
- package/config/web-inspector/index.html +2 -2
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +180 -115
- package/config/webpackDevServer.config.js +49 -79
- package/lib/types/base.d.ts +13 -2
- package/package.json +62 -48
- package/scripts/build.js +41 -19
- package/scripts/eject.js +237 -234
- package/scripts/init.js +10 -12
- package/scripts/lint.js +4 -3
- package/scripts/start.js +40 -40
- package/scripts/test.js +129 -0
- package/scripts/utils/createJestConfig.js +152 -0
- package/scripts/utils/verifyTypeScriptSetup.js +306 -309
- package/config/pnpTs.js +0 -43
- package/config/react-error-overlay.js +0 -9
- package/config/refreshOverlayInterop.js +0 -4
- package/config/webpackHotDevClient.js +0 -268
- package/scripts/utils/verifyPackageTree.js +0 -161
|
@@ -1 +1 @@
|
|
|
1
|
-
function createUnityInstance(e,r,t){function n(e,t){if(!n.aborted&&r.showBanner)return"error"==t&&(n.aborted=!0),r.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function o(e){var r=e.reason||e.error,t=r?r.toString():e.message||e.reason||"",n=r&&r.stack?r.stack.toString():"";if(n.startsWith(t)&&(n=n.substring(t.length)),t+="\n"+n.trim(),t&&c.stackTraceRegExp&&c.stackTraceRegExp.test(t)){var o=e.filename||r&&(r.fileName||r.sourceURL)||"",a=e.lineno||r&&(r.lineNumber||r.line)||0;s(t,o,a)}}function a(e){e.preventDefault()}function s(e,r,t){if(e.indexOf("fullscreen error")==-1){if(c.startupErrorHandler)return void c.startupErrorHandler(e,r,t);if(!(c.errorHandler&&c.errorHandler(e,r,t)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),s.didShowErrorMessage))){var e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e;e.indexOf("DISABLE_EXCEPTION_CATCHING")!=-1?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":e.indexOf("Cannot enlarge memory arrays")!=-1?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":e.indexOf("Invalid array buffer length")==-1&&e.indexOf("Invalid typed array length")==-1&&e.indexOf("out of memory")==-1&&e.indexOf("could not allocate memory")==-1||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),s.didShowErrorMessage=!0}}}function i(e,r){if("symbolsUrl"!=e){var n=c.downloadProgress[e];n||(n=c.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof r||"progress"!=r.type&&"load"!=r.type||(n.started||(n.started=!0,n.lengthComputable=r.lengthComputable,n.total=r.total),n.loaded=r.loaded,"load"==r.type&&(n.finished=!0));var o=0,a=0,s=0,i=0,d=0;for(var e in c.downloadProgress){var n=c.downloadProgress[e];if(!n.started)return 0;s++,n.lengthComputable?(o+=n.loaded,a+=n.total,i++):n.finished||d++}var l=s?(s-d-(a?i*(a-o)/a:0))/s:0;t(.9*l)}}function d(e){return new Promise(function(r,t){i(e);var o=c.companyName&&c.productName?new c.XMLHttpRequest({companyName:c.companyName,productName:c.productName,cacheControl:c.cacheControl(c[e])}):new XMLHttpRequest;o.open("GET",c[e]),o.responseType="arraybuffer",o.addEventListener("progress",function(r){i(e,r)}),o.addEventListener("load",function(t){i(e,t),r(new Uint8Array(o.response))}),o.addEventListener("error",function(r){var t="Failed to download file "+c[e];"file:"==location.protocol?n(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}),o.send()})}function l(){return new Promise(function(e,r){var t=document.createElement("script");t.src=c.frameworkUrl,t.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var r=[["br","br"],["gz","gzip"]];for(var o in r){var a=r[o];if(c.frameworkUrl.endsWith("."+a[0])){var s="Unable to parse "+c.frameworkUrl+"!";if("file:"==location.protocol)return void n(s+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error");if(s+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+a[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==a[0]&&"http:"==location.protocol){var i=["localhost","127.0.0.1"].indexOf(location.hostname)!=-1?"":"Migrate your server to use HTTPS.";s=/Firefox/.test(navigator.userAgent)?"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+i+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'}return void n(s,"error")}}n("Unable to parse "+c.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var d=unityFramework;unityFramework=null,t.onload=null,e(d)},t.onerror=function(e){n("Unable to load file "+c.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(t),c.deinitializers.push(function(){document.body.removeChild(t)})})}function u(){l().then(function(e){e(c)});var e=d("dataUrl");c.preRun.push(function(){c.addRunDependency("dataUrl"),e.then(function(e){var r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0,n="UnityWebData1.0\0";if(!String.fromCharCode.apply(null,e.subarray(t,t+n.length))==n)throw"unknown data format";t+=n.length;var o=r.getUint32(t,!0);for(t+=4;t<o;){var a=r.getUint32(t,!0);t+=4;var s=r.getUint32(t,!0);t+=4;var i=r.getUint32(t,!0);t+=4;var d=String.fromCharCode.apply(null,e.subarray(t,t+i));t+=i;for(var l=0,u=d.indexOf("/",l)+1;u>0;l=u,u=d.indexOf("/",l)+1)c.FS_createPath(d.substring(0,l),d.substring(l,u-1),!0,!0);c.FS_createDataFile(d,null,e.subarray(a,a+s),!0,!0,!0)}c.removeRunDependency("dataUrl")})})}t=t||function(){};var c={canvas:e,webglContextAttributes:{preserveDrawingBuffer:!1},cacheControl:function(e){return e==c.dataUrl?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,r){var t=window.setInterval(e,r);return this.intervals[t]=!0,t},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&e.indexOf("wasm streaming compile failed")!=-1&&(e.toLowerCase().indexOf("mime")!=-1?n('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+c.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):n('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+c.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(var f in r)c[f]=r[f];c.streamingAssetsUrl=new URL(c.streamingAssetsUrl,document.URL).href;var p=c.disabledCanvasEvents.slice();p.forEach(function(r){e.addEventListener(r,a)}),window.addEventListener("error",o),window.addEventListener("unhandledrejection",o);var h={Module:c,SetFullscreen:function(){return c.SetFullscreen?c.SetFullscreen.apply(c,arguments):void c.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){return c.SendMessage?c.SendMessage.apply(c,arguments):void c.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(r,t){c.shouldQuit=!0,c.onQuit=r,p.forEach(function(r){e.removeEventListener(r,a)}),window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",o)})}};return c.SystemInfo=function(){function e(e,r,t){return e=RegExp(e,"i").exec(r),e&&e[t]}for(var r,t,n,o,a,s,i=navigator.userAgent+" ",d=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]],l=0;l<d.length;++l)if(t=e(d[l][0]+"[/ ](.*?)[ \\)]",i,1)){r=d[l][1];break}"Safari"==r&&(t=e("Version/(.*?) ",i,1)),"Internet Explorer"==r&&(t=e("rv:(.*?)\\)? ",i,1)||t);for(var u=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_.]+)","macOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],c=0;c<u.length;++c)if(o=e(u[c][0],i,1)){n=u[c][1],o=o.replace(/_/g,".");break}var f={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"};o=f[o]||o,a=document.createElement("canvas"),a&&(gl=a.getContext("webgl2"),glVersion=gl?2:0,gl||(gl=a&&a.getContext("webgl"))&&(glVersion=1),gl&&(s=gl.getExtension("WEBGL_debug_renderer_info")&&gl.getParameter(37446)||gl.getParameter(7937)));var p="undefined"!=typeof SharedArrayBuffer,h="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile;return{width:screen.width,height:screen.height,userAgent:i.trim(),browser:r||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:o||"Unknown OS Version",gpu:s||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:glVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:p,hasWasm:h,hasWasmThreads:!1}}(),c.abortHandler=function(e){return s(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),c.XMLHttpRequest=function(){function e(e){console.log("[UnityCache] "+e)}function r(e){return r.link=r.link||document.createElement("a"),r.link.href=e,r.link.href}function t(e){var r=window.location.href.match(/^[a-z]+:\/\/[^\/]+/);return!r||e.lastIndexOf(r[0],0)}function n(){function r(r){if("undefined"==typeof n.database)for(n.database=r,n.database||e("indexedDB database could not be opened");n.queue.length;){var t=n.queue.shift();n.database?n.execute.apply(n,t.arguments):"function"==typeof t.onerror&&t.onerror(new Error("operation cancelled"))}}function t(){var e=o.open(s.name,s.version);e.onupgradeneeded=function(e){var r=e.target.result;r.objectStoreNames.contains(d.name)||r.createObjectStore(d.name)},e.onsuccess=function(e){r(e.target.result)},e.onerror=function(){r(null)}}var n=this;n.queue=[];try{var o=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,a=setTimeout(function(){"undefined"==typeof n.database&&r(null)},2e3),l=o.open(s.name);l.onupgradeneeded=function(e){var r=e.target.result.createObjectStore(i.name,{keyPath:"url"});["version","company","product","updated","revalidated","accessed"].forEach(function(e){r.createIndex(e,e)})},l.onsuccess=function(e){clearTimeout(a);var n=e.target.result;n.version<s.version?(n.close(),t()):r(n)},l.onerror=function(){clearTimeout(a),r(null)}}catch(e){clearTimeout(a),r(null)}}function o(e,r,t,n,o){var a={url:e,version:i.version,company:r,product:t,updated:n,revalidated:n,accessed:n,responseHeaders:{},xhr:{}};return o&&(["Last-Modified","ETag"].forEach(function(e){a.responseHeaders[e]=o.getResponseHeader(e)}),["responseURL","status","statusText","response"].forEach(function(e){a.xhr[e]=o[e]})),a}function a(r){this.cache={enabled:!1},r&&(this.cache.control=r.cacheControl,this.cache.company=r.companyName,this.cache.product=r.productName),this.xhr=new XMLHttpRequest(r),this.xhr.addEventListener("load",function(){var r=this.xhr,t=this.cache;t.enabled&&!t.revalidated&&(304==r.status?(t.result.revalidated=t.result.accessed,t.revalidated=!0,l.execute(i.name,"put",[t.result]),e("'"+t.result.url+"' successfully revalidated and served from the indexedDB cache")):200==r.status?(t.result=o(t.result.url,t.company,t.product,t.result.accessed,r),t.revalidated=!0,l.execute(i.name,"put",[t.result],function(r){e("'"+t.result.url+"' successfully downloaded and stored in the indexedDB cache")},function(r){e("'"+t.result.url+"' successfully downloaded but not stored in the indexedDB cache due to the error: "+r)})):e("'"+t.result.url+"' request failed with status: "+r.status+" "+r.statusText))}.bind(this))}var s={name:"UnityCache",version:2},i={name:"XMLHttpRequest",version:1},d={name:"WebAssembly",version:1};n.prototype.execute=function(e,r,t,n,o){if(this.database)try{var a=this.database.transaction([e],["put","delete","clear"].indexOf(r)!=-1?"readwrite":"readonly").objectStore(e);"openKeyCursor"==r&&(a=a.index(t[0]),t=t.slice(1));var s=a[r].apply(a,t);"function"==typeof n&&(s.onsuccess=function(e){n(e.target.result)}),s.onerror=o}catch(e){"function"==typeof o&&o(e)}else"undefined"==typeof this.database?this.queue.push({arguments:arguments,onerror:o}):"function"==typeof o&&o(new Error("indexedDB access denied"))};var l=new n;a.prototype.send=function(r){var n=this.xhr,o=this.cache,a=arguments;return o.enabled=o.enabled&&"arraybuffer"==n.responseType&&!r,o.enabled?void l.execute(i.name,"get",[o.result.url],function(r){if(!r||r.version!=i.version)return void n.send.apply(n,a);if(o.result=r,o.result.accessed=Date.now(),"immutable"==o.control)o.revalidated=!0,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' served from the indexedDB cache without revalidation");else if(t(o.result.url)&&(o.result.responseHeaders["Last-Modified"]||o.result.responseHeaders.ETag)){var s=new XMLHttpRequest;s.open("HEAD",o.result.url),s.onload=function(){o.revalidated=["Last-Modified","ETag"].every(function(e){return!o.result.responseHeaders[e]||o.result.responseHeaders[e]==s.getResponseHeader(e)}),o.revalidated?(o.result.revalidated=o.result.accessed,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' successfully revalidated and served from the indexedDB cache")):n.send.apply(n,a)},s.onerror=function(){n.send.apply(n,a)},s.send()}else o.result.responseHeaders["Last-Modified"]?(n.setRequestHeader("If-Modified-Since",o.result.responseHeaders["Last-Modified"]),n.setRequestHeader("Cache-Control","no-cache")):o.result.responseHeaders.ETag&&(n.setRequestHeader("If-None-Match",o.result.responseHeaders.ETag),n.setRequestHeader("Cache-Control","no-cache")),n.send.apply(n,a)},function(e){n.send.apply(n,a)}):n.send.apply(n,a)},a.prototype.open=function(e,t,n,a,s){return this.cache.result=o(r(t),this.cache.company,this.cache.product,Date.now()),this.cache.enabled=["must-revalidate","immutable"].indexOf(this.cache.control)!=-1&&"GET"==e&&this.cache.result.url.match("^https?://")&&("undefined"==typeof n||n)&&"undefined"==typeof a&&"undefined"==typeof s,this.cache.revalidated=!1,this.xhr.open.apply(this.xhr,arguments)},a.prototype.setRequestHeader=function(e,r){return this.cache.enabled=!1,this.xhr.setRequestHeader.apply(this.xhr,arguments)};var u=new XMLHttpRequest;for(var c in u)a.prototype.hasOwnProperty(c)||!function(e){Object.defineProperty(a.prototype,e,"function"==typeof u[e]?{value:function(){return this.xhr[e].apply(this.xhr,arguments)}}:{get:function(){return this.cache.revalidated&&this.cache.result.xhr.hasOwnProperty(e)?this.cache.result.xhr[e]:this.xhr[e]},set:function(r){this.xhr[e]=r}})}(c);return a}(),new Promise(function(e,r){c.SystemInfo.hasWebGL?c.SystemInfo.hasWasm?(1==c.SystemInfo.hasWebGL&&c.print('Warning: Your browser does not support "WebGL 2" Graphics API, switching to "WebGL 1"'),c.startupErrorHandler=r,t(0),c.postRun.push(function(){t(1),delete c.startupErrorHandler,e(h)}),u()):r("Your browser does not support WebAssembly."):r("Your browser does not support WebGL.")})}
|
|
1
|
+
function createUnityInstance(e,r,t){function n(e,t){if(!n.aborted&&r.showBanner)return"error"==t&&(n.aborted=!0),r.showBanner(e,t);switch(t){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function o(e){var r=e.reason||e.error,t=r?r.toString():e.message||e.reason||"",n=r&&r.stack?r.stack.toString():"";if(n.startsWith(t)&&(n=n.substring(t.length)),t+="\n"+n.trim(),t&&c.stackTraceRegExp&&c.stackTraceRegExp.test(t)){var o=e.filename||r&&(r.fileName||r.sourceURL)||"",a=e.lineno||r&&(r.lineNumber||r.line)||0;s(t,o,a)}}function a(e){e.preventDefault()}function s(e,r,t){if(c.startupErrorHandler)return void c.startupErrorHandler(e,r,t);if(!(c.errorHandler&&c.errorHandler(e,r,t)||(console.log("Invoking error handler due to\n"+e),"function"==typeof dump&&dump("Invoking error handler due to\n"+e),e.indexOf("UnknownError")!=-1||e.indexOf("Program terminated with exit(0)")!=-1||s.didShowErrorMessage))){var e="An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:\n"+e;e.indexOf("DISABLE_EXCEPTION_CATCHING")!=-1?e="An exception has occurred, but exception handling has been disabled in this build. If you are the developer of this content, enable exceptions in your project WebGL player settings to be able to catch the exception or see the stack trace.":e.indexOf("Cannot enlarge memory arrays")!=-1?e="Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings.":e.indexOf("Invalid array buffer length")==-1&&e.indexOf("Invalid typed array length")==-1&&e.indexOf("out of memory")==-1&&e.indexOf("could not allocate memory")==-1||(e="The browser could not allocate enough memory for the WebGL content. If you are the developer of this content, try allocating less memory to your WebGL build in the WebGL player settings."),alert(e),s.didShowErrorMessage=!0}}function i(e,r){if("symbolsUrl"!=e){var n=c.downloadProgress[e];n||(n=c.downloadProgress[e]={started:!1,finished:!1,lengthComputable:!1,total:0,loaded:0}),"object"!=typeof r||"progress"!=r.type&&"load"!=r.type||(n.started||(n.started=!0,n.lengthComputable=r.lengthComputable,n.total=r.total),n.loaded=r.loaded,"load"==r.type&&(n.finished=!0));var o=0,a=0,s=0,i=0,d=0;for(var e in c.downloadProgress){var n=c.downloadProgress[e];if(!n.started)return 0;s++,n.lengthComputable?(o+=n.loaded,a+=n.total,i++):n.finished||d++}var l=s?(s-d-(a?i*(a-o)/a:0))/s:0;t(.9*l)}}function d(e){return new Promise(function(r,t){i(e);var o=c.companyName&&c.productName?new c.XMLHttpRequest({companyName:c.companyName,productName:c.productName,cacheControl:c.cacheControl(c[e])}):new XMLHttpRequest;o.open("GET",c[e]),o.responseType="arraybuffer",o.addEventListener("progress",function(r){i(e,r)}),o.addEventListener("load",function(t){i(e,t),r(new Uint8Array(o.response))}),o.addEventListener("error",function(r){var t="Failed to download file "+c[e];"file:"==location.protocol?n(t+". Loading web pages via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host Unity content, or use the Unity Build and Run option.","error"):console.error(t)}),o.send()})}function l(){return new Promise(function(e,r){var t=document.createElement("script");t.src=c.frameworkUrl,t.onload=function(){if("undefined"==typeof unityFramework||!unityFramework){var r=[["br","br"],["gz","gzip"]];for(var o in r){var a=r[o];if(c.frameworkUrl.endsWith("."+a[0])){var s="Unable to parse "+c.frameworkUrl+"!";if("file:"==location.protocol)return void n(s+" Loading pre-compressed (brotli or gzip) content via a file:// URL without a web server is not supported by this browser. Please use a local development web server to host compressed Unity content, or use the Unity Build and Run option.","error");if(s+=' This can happen if build compression was enabled but web server hosting the content was misconfigured to not serve the file with HTTP Response Header "Content-Encoding: '+a[1]+'" present. Check browser Console and Devtools Network tab to debug.',"br"==a[0]&&"http:"==location.protocol){var i=["localhost","127.0.0.1"].indexOf(location.hostname)!=-1?"":"Migrate your server to use HTTPS.";s=/Firefox/.test(navigator.userAgent)?"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported in Firefox over HTTP connections. '+i+' See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1670675">https://bugzilla.mozilla.org/show_bug.cgi?id=1670675</a> for more information.':"Unable to parse "+c.frameworkUrl+'!<br>If using custom web server, verify that web server is sending .br files with HTTP Response Header "Content-Encoding: br". Brotli compression may not be supported over HTTP connections. Migrate your server to use HTTPS.'}return void n(s,"error")}}n("Unable to parse "+c.frameworkUrl+"! The file is corrupt, or compression was misconfigured? (check Content-Encoding HTTP Response Header on web server)","error")}var d=unityFramework;unityFramework=null,t.onload=null,e(d)},t.onerror=function(e){n("Unable to load file "+c.frameworkUrl+"! Check that the file exists on the remote server. (also check browser Console and Devtools Network tab to debug)","error")},document.body.appendChild(t),c.deinitializers.push(function(){document.body.removeChild(t)})})}function u(){l().then(function(e){e(c)});var e=d("dataUrl");c.preRun.push(function(){c.addRunDependency("dataUrl"),e.then(function(e){var r=new DataView(e.buffer,e.byteOffset,e.byteLength),t=0,n="UnityWebData1.0\0";if(!String.fromCharCode.apply(null,e.subarray(t,t+n.length))==n)throw"unknown data format";t+=n.length;var o=r.getUint32(t,!0);for(t+=4;t<o;){var a=r.getUint32(t,!0);t+=4;var s=r.getUint32(t,!0);t+=4;var i=r.getUint32(t,!0);t+=4;var d=String.fromCharCode.apply(null,e.subarray(t,t+i));t+=i;for(var l=0,u=d.indexOf("/",l)+1;u>0;l=u,u=d.indexOf("/",l)+1)c.FS_createPath(d.substring(0,l),d.substring(l,u-1),!0,!0);c.FS_createDataFile(d,null,e.subarray(a,a+s),!0,!0,!0)}c.removeRunDependency("dataUrl")})})}t=t||function(){};var c={canvas:e,webglContextAttributes:{preserveDrawingBuffer:!1},cacheControl:function(e){return e==c.dataUrl?"must-revalidate":"no-store"},streamingAssetsUrl:"StreamingAssets",downloadProgress:{},deinitializers:[],intervals:{},setInterval:function(e,r){var t=window.setInterval(e,r);return this.intervals[t]=!0,t},clearInterval:function(e){delete this.intervals[e],window.clearInterval(e)},preRun:[],postRun:[],print:function(e){console.log(e)},printErr:function(e){console.error(e),"string"==typeof e&&e.indexOf("wasm streaming compile failed")!=-1&&(e.toLowerCase().indexOf("mime")!=-1?n('HTTP Response Header "Content-Type" configured incorrectly on the server for file '+c.codeUrl+' , should be "application/wasm". Startup time performance will suffer.',"warning"):n('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file '+c.codeUrl+", but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.","warning"))},locateFile:function(e){return"build.wasm"==e?this.codeUrl:e},disabledCanvasEvents:["contextmenu","dragstart"]};for(var f in r)c[f]=r[f];c.streamingAssetsUrl=new URL(c.streamingAssetsUrl,document.URL).href;var h=c.disabledCanvasEvents.slice();h.forEach(function(r){e.addEventListener(r,a)}),window.addEventListener("error",o),window.addEventListener("unhandledrejection",o);var p="",m="";document.addEventListener("webkitfullscreenchange",function(r){var t=document.webkitCurrentFullScreenElement;t===e?e.style.width&&(p=e.style.width,m=e.style.height,e.style.width="100%",e.style.height="100%"):p&&(e.style.width=p,e.style.height=m,p="",m="")});var v={Module:c,SetFullscreen:function(){return c.SetFullscreen?c.SetFullscreen.apply(c,arguments):void c.print("Failed to set Fullscreen mode: Player not loaded yet.")},SendMessage:function(){return c.SendMessage?c.SendMessage.apply(c,arguments):void c.print("Failed to execute SendMessage: Player not loaded yet.")},Quit:function(){return new Promise(function(r,t){c.shouldQuit=!0,c.onQuit=r,h.forEach(function(r){e.removeEventListener(r,a)}),window.removeEventListener("error",o),window.removeEventListener("unhandledrejection",o)})}};return c.SystemInfo=function(){function e(e,r,t){return e=RegExp(e,"i").exec(r),e&&e[t]}for(var r,t,n,o,a,s,i=navigator.userAgent+" ",d=[["Firefox","Firefox"],["OPR","Opera"],["Edg","Edge"],["SamsungBrowser","Samsung Browser"],["Trident","Internet Explorer"],["MSIE","Internet Explorer"],["Chrome","Chrome"],["CriOS","Chrome on iOS Safari"],["FxiOS","Firefox on iOS Safari"],["Safari","Safari"]],l=0;l<d.length;++l)if(t=e(d[l][0]+"[/ ](.*?)[ \\)]",i,1)){r=d[l][1];break}"Safari"==r&&(t=e("Version/(.*?) ",i,1)),"Internet Explorer"==r&&(t=e("rv:(.*?)\\)? ",i,1)||t);for(var u=[["Windows (.*?)[;)]","Windows"],["Android ([0-9_.]+)","Android"],["iPhone OS ([0-9_.]+)","iPhoneOS"],["iPad.*? OS ([0-9_.]+)","iPadOS"],["FreeBSD( )","FreeBSD"],["OpenBSD( )","OpenBSD"],["Linux|X11()","Linux"],["Mac OS X ([0-9_.]+)","macOS"],["bot|google|baidu|bing|msn|teoma|slurp|yandex","Search Bot"]],c=0;c<u.length;++c)if(o=e(u[c][0],i,1)){n=u[c][1],o=o.replace(/_/g,".");break}var f={"NT 5.0":"2000","NT 5.1":"XP","NT 5.2":"Server 2003","NT 6.0":"Vista","NT 6.1":"7","NT 6.2":"8","NT 6.3":"8.1","NT 10.0":"10"};o=f[o]||o,a=document.createElement("canvas"),a&&(gl=a.getContext("webgl2"),glVersion=gl?2:0,gl||(gl=a&&a.getContext("webgl"))&&(glVersion=1),gl&&(s=gl.getExtension("WEBGL_debug_renderer_info")&&gl.getParameter(37446)||gl.getParameter(7937)));var h="undefined"!=typeof SharedArrayBuffer,p="object"==typeof WebAssembly&&"function"==typeof WebAssembly.compile;return{width:screen.width,height:screen.height,userAgent:i.trim(),browser:r||"Unknown browser",browserVersion:t||"Unknown version",mobile:/Mobile|Android|iP(ad|hone)/.test(navigator.appVersion),os:n||"Unknown OS",osVersion:o||"Unknown OS Version",gpu:s||"Unknown GPU",language:navigator.userLanguage||navigator.language,hasWebGL:glVersion,hasCursorLock:!!document.body.requestPointerLock,hasFullscreen:!!document.body.requestFullscreen||!!document.body.webkitRequestFullscreen,hasThreads:h,hasWasm:p,hasWasmThreads:!1}}(),c.abortHandler=function(e){return s(e,"",0),!0},Error.stackTraceLimit=Math.max(Error.stackTraceLimit||0,50),c.XMLHttpRequest=function(){function e(e){console.log("[UnityCache] "+e)}function r(e){return r.link=r.link||document.createElement("a"),r.link.href=e,r.link.href}function t(e){var r=window.location.href.match(/^[a-z]+:\/\/[^\/]+/);return!r||e.lastIndexOf(r[0],0)}function n(){function r(r){if("undefined"==typeof n.database)for(n.database=r,n.database||e("indexedDB database could not be opened");n.queue.length;){var t=n.queue.shift();n.database?n.execute.apply(n,t.arguments):"function"==typeof t.onerror&&t.onerror(new Error("operation cancelled"))}}function t(){var e=o.open(s.name,s.version);e.onupgradeneeded=function(e){var r=e.target.result;r.objectStoreNames.contains(d.name)||r.createObjectStore(d.name)},e.onsuccess=function(e){r(e.target.result)},e.onerror=function(){r(null)}}var n=this;n.queue=[];try{var o=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,a=setTimeout(function(){"undefined"==typeof n.database&&r(null)},2e3),l=o.open(s.name);l.onupgradeneeded=function(e){var r=e.target.result.createObjectStore(i.name,{keyPath:"url"});["version","company","product","updated","revalidated","accessed"].forEach(function(e){r.createIndex(e,e)})},l.onsuccess=function(e){clearTimeout(a);var n=e.target.result;n.version<s.version?(n.close(),t()):r(n)},l.onerror=function(){clearTimeout(a),r(null)}}catch(e){clearTimeout(a),r(null)}}function o(e,r,t,n,o){var a={url:e,version:i.version,company:r,product:t,updated:n,revalidated:n,accessed:n,responseHeaders:{},xhr:{}};return o&&(["Last-Modified","ETag"].forEach(function(e){a.responseHeaders[e]=o.getResponseHeader(e)}),["responseURL","status","statusText","response"].forEach(function(e){a.xhr[e]=o[e]})),a}function a(r){this.cache={enabled:!1},r&&(this.cache.control=r.cacheControl,this.cache.company=r.companyName,this.cache.product=r.productName),this.xhr=new XMLHttpRequest(r),this.xhr.addEventListener("load",function(){var r=this.xhr,t=this.cache;t.enabled&&!t.revalidated&&(304==r.status?(t.result.revalidated=t.result.accessed,t.revalidated=!0,l.execute(i.name,"put",[t.result]),e("'"+t.result.url+"' successfully revalidated and served from the indexedDB cache")):200==r.status?(t.result=o(t.result.url,t.company,t.product,t.result.accessed,r),t.revalidated=!0,l.execute(i.name,"put",[t.result],function(r){e("'"+t.result.url+"' successfully downloaded and stored in the indexedDB cache")},function(r){e("'"+t.result.url+"' successfully downloaded but not stored in the indexedDB cache due to the error: "+r)})):e("'"+t.result.url+"' request failed with status: "+r.status+" "+r.statusText))}.bind(this))}var s={name:"UnityCache",version:2},i={name:"XMLHttpRequest",version:1},d={name:"WebAssembly",version:1};n.prototype.execute=function(e,r,t,n,o){if(this.database)try{var a=this.database.transaction([e],["put","delete","clear"].indexOf(r)!=-1?"readwrite":"readonly").objectStore(e);"openKeyCursor"==r&&(a=a.index(t[0]),t=t.slice(1));var s=a[r].apply(a,t);"function"==typeof n&&(s.onsuccess=function(e){n(e.target.result)}),s.onerror=o}catch(e){"function"==typeof o&&o(e)}else"undefined"==typeof this.database?this.queue.push({arguments:arguments,onerror:o}):"function"==typeof o&&o(new Error("indexedDB access denied"))};var l=new n;a.prototype.send=function(r){var n=this.xhr,o=this.cache,a=arguments;return o.enabled=o.enabled&&"arraybuffer"==n.responseType&&!r,o.enabled?void l.execute(i.name,"get",[o.result.url],function(r){if(!r||r.version!=i.version)return void n.send.apply(n,a);if(o.result=r,o.result.accessed=Date.now(),"immutable"==o.control)o.revalidated=!0,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' served from the indexedDB cache without revalidation");else if(t(o.result.url)&&(o.result.responseHeaders["Last-Modified"]||o.result.responseHeaders.ETag)){var s=new XMLHttpRequest;s.open("HEAD",o.result.url),s.onload=function(){o.revalidated=["Last-Modified","ETag"].every(function(e){return!o.result.responseHeaders[e]||o.result.responseHeaders[e]==s.getResponseHeader(e)}),o.revalidated?(o.result.revalidated=o.result.accessed,l.execute(i.name,"put",[o.result]),n.dispatchEvent(new Event("load")),e("'"+o.result.url+"' successfully revalidated and served from the indexedDB cache")):n.send.apply(n,a)},s.send()}else o.result.responseHeaders["Last-Modified"]?(n.setRequestHeader("If-Modified-Since",o.result.responseHeaders["Last-Modified"]),n.setRequestHeader("Cache-Control","no-cache")):o.result.responseHeaders.ETag&&(n.setRequestHeader("If-None-Match",o.result.responseHeaders.ETag),n.setRequestHeader("Cache-Control","no-cache")),n.send.apply(n,a)},function(e){n.send.apply(n,a)}):n.send.apply(n,a)},a.prototype.open=function(e,t,n,a,s){return this.cache.result=o(r(t),this.cache.company,this.cache.product,Date.now()),this.cache.enabled=["must-revalidate","immutable"].indexOf(this.cache.control)!=-1&&"GET"==e&&this.cache.result.url.match("^https?://")&&("undefined"==typeof n||n)&&"undefined"==typeof a&&"undefined"==typeof s,this.cache.revalidated=!1,this.xhr.open.apply(this.xhr,arguments)},a.prototype.setRequestHeader=function(e,r){return this.cache.enabled=!1,this.xhr.setRequestHeader.apply(this.xhr,arguments)};var u=new XMLHttpRequest;for(var c in u)a.prototype.hasOwnProperty(c)||!function(e){Object.defineProperty(a.prototype,e,"function"==typeof u[e]?{value:function(){return this.xhr[e].apply(this.xhr,arguments)}}:{get:function(){return this.cache.revalidated&&this.cache.result.xhr.hasOwnProperty(e)?this.cache.result.xhr[e]:this.xhr[e]},set:function(r){this.xhr[e]=r}})}(c);return a}(),new Promise(function(e,r){c.SystemInfo.hasWebGL?c.SystemInfo.hasWasm?(1==c.SystemInfo.hasWebGL&&c.print('Warning: Your browser does not support "WebGL 2.0" Graphics API, switching to "WebGL 1.0"'),c.startupErrorHandler=r,t(0),c.postRun.push(function(){t(1),delete c.startupErrorHandler,e(v)}),u()):r("Your browser does not support WebAssembly."):r("Your browser does not support WebGL.")})}
|
|
Binary file
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
height: 100%;
|
|
51
51
|
background: #3f51b5;
|
|
52
52
|
}
|
|
53
|
+
|
|
53
54
|
</style>
|
|
54
55
|
</head>
|
|
55
56
|
|
|
56
57
|
<body style="text-align: center">
|
|
57
|
-
<canvas id="unity-canvas"
|
|
58
|
-
style="background: #231F20"></canvas>
|
|
58
|
+
<canvas id="unity-canvas" style="background: #231F20"></canvas>
|
|
59
59
|
|
|
60
60
|
<div class="loader-center" id="loader-root">
|
|
61
61
|
<div class="loader">
|
package/config/webpack.config.js
CHANGED
|
@@ -12,10 +12,10 @@ const fs = require('fs');
|
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const webpack = require('webpack');
|
|
14
14
|
const resolve = require('resolve');
|
|
15
|
-
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
|
16
15
|
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
|
17
16
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
18
|
-
const
|
|
17
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
18
|
+
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
|
19
19
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
20
20
|
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
|
|
21
21
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
@@ -24,28 +24,43 @@ const paths = require('./paths');
|
|
|
24
24
|
const modules = require('./modules');
|
|
25
25
|
const getClientEnvironment = require('./env');
|
|
26
26
|
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
|
|
27
|
-
const ForkTsCheckerWebpackPlugin =
|
|
28
|
-
|
|
27
|
+
const ForkTsCheckerWebpackPlugin =
|
|
28
|
+
process.env.TSC_COMPILE_ON_ERROR === 'true'
|
|
29
|
+
? require('react-dev-utils/ForkTsCheckerWarningWebpackPlugin')
|
|
30
|
+
: require('react-dev-utils/ForkTsCheckerWebpackPlugin');
|
|
29
31
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
30
|
-
const restrictedGlobals = require('confusing-browser-globals');
|
|
31
32
|
// @remove-on-eject-begin
|
|
32
33
|
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
|
|
33
34
|
// @remove-on-eject-end
|
|
34
|
-
|
|
35
|
+
const createEnvironmentHash = require('./webpack/persistentCache/createEnvironmentHash');
|
|
35
36
|
|
|
36
37
|
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
|
38
|
+
|
|
37
39
|
const sourceMapVar = process.env.GENERATE_SOURCEMAP;
|
|
38
40
|
const shouldUseSourceMap = sourceMapVar !== 'false' && !!sourceMapVar;
|
|
39
41
|
const sourceMapType = sourceMapVar !== 'false' && sourceMapVar !== 'true' && sourceMapVar;
|
|
40
42
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
+
const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');
|
|
44
|
+
const reactRefreshWebpackPluginRuntimeEntry = require.resolve(
|
|
45
|
+
'@pmmmwh/react-refresh-webpack-plugin'
|
|
43
46
|
);
|
|
44
|
-
const
|
|
45
|
-
|
|
47
|
+
const babelRuntimeEntry = require.resolve('babel-preset-react-app');
|
|
48
|
+
const babelRuntimeEntryHelpers = require.resolve(
|
|
49
|
+
'@babel/runtime/helpers/esm/assertThisInitialized',
|
|
50
|
+
{ paths: [babelRuntimeEntry] }
|
|
46
51
|
);
|
|
52
|
+
const babelRuntimeRegenerator = require.resolve('@babel/runtime/regenerator', {
|
|
53
|
+
paths: [babelRuntimeEntry],
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
|
|
57
|
+
// makes for a smoother build process.
|
|
58
|
+
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK === 'true';
|
|
59
|
+
|
|
47
60
|
const emitErrorsAsWarnings = process.env.ESLINT_NO_DEV_ERRORS === 'true';
|
|
48
61
|
const disableESLintPlugin = process.env.DISABLE_ESLINT_PLUGIN === 'true';
|
|
62
|
+
const extractCss = process.env.EXTRACT_CSS === 'true';
|
|
63
|
+
const generateManifest = process.env.GENERATE_MANIFEST !== 'false';
|
|
49
64
|
|
|
50
65
|
const imageInlineSizeLimit = parseInt(
|
|
51
66
|
process.env.IMAGE_INLINE_SIZE_LIMIT || '0'
|
|
@@ -54,6 +69,11 @@ const imageInlineSizeLimit = parseInt(
|
|
|
54
69
|
// Check if TypeScript is setup
|
|
55
70
|
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
|
56
71
|
|
|
72
|
+
// Check if Tailwind config exists
|
|
73
|
+
const useTailwind = fs.existsSync(
|
|
74
|
+
path.join(paths.appPath, 'tailwind.config.js')
|
|
75
|
+
);
|
|
76
|
+
|
|
57
77
|
// style files regexes
|
|
58
78
|
const cssRegex = /\.css$/;
|
|
59
79
|
const cssModuleRegex = /\.module\.css$/;
|
|
@@ -65,6 +85,7 @@ const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
|
65
85
|
module.exports = function (webpackEnv) {
|
|
66
86
|
const isEnvDevelopment = webpackEnv === 'development';
|
|
67
87
|
const isEnvProduction = webpackEnv === 'production';
|
|
88
|
+
const shouldExtractCss = isEnvProduction && extractCss;
|
|
68
89
|
|
|
69
90
|
// Variable used for enabling profiling in Production
|
|
70
91
|
// passed into alias object. Uses a flag if passed into the build command
|
|
@@ -82,13 +103,35 @@ module.exports = function (webpackEnv) {
|
|
|
82
103
|
// common function to get style loaders
|
|
83
104
|
const getStyleLoaders = (cssOptions, preProcessor) => {
|
|
84
105
|
const loaders = [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
106
|
+
!shouldExtractCss ? require.resolve('style-loader')
|
|
107
|
+
: {
|
|
108
|
+
loader: MiniCssExtractPlugin.loader,
|
|
109
|
+
// css is located in `static/css`, use '../../' to locate index.html folder
|
|
110
|
+
// in production `paths.publicUrlOrPath` can be a relative path
|
|
111
|
+
options: paths.publicUrlOrPath.startsWith('.')
|
|
112
|
+
? { publicPath: '../../' }
|
|
113
|
+
: {},
|
|
114
|
+
},
|
|
88
115
|
{
|
|
89
116
|
loader: require.resolve('css-loader'),
|
|
90
117
|
options: cssOptions,
|
|
91
118
|
},
|
|
119
|
+
useTailwind && {
|
|
120
|
+
// Options for PostCSS as we reference these options twice
|
|
121
|
+
// Adds vendor prefixing based on your specified browser support in
|
|
122
|
+
// package.json
|
|
123
|
+
loader: require.resolve('postcss-loader'),
|
|
124
|
+
options: {
|
|
125
|
+
postcssOptions: {
|
|
126
|
+
// Necessary for external CSS imports to work
|
|
127
|
+
// https://github.com/facebook/create-react-app/issues/2677
|
|
128
|
+
ident: 'postcss',
|
|
129
|
+
config: false,
|
|
130
|
+
plugins: ['tailwindcss'],
|
|
131
|
+
},
|
|
132
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
92
135
|
].filter(Boolean);
|
|
93
136
|
if (preProcessor) {
|
|
94
137
|
loaders.push(
|
|
@@ -121,40 +164,20 @@ module.exports = function (webpackEnv) {
|
|
|
121
164
|
: isEnvDevelopment && (sourceMapType || 'eval-source-map'),
|
|
122
165
|
// These are the "entry points" to our application.
|
|
123
166
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
124
|
-
entry:
|
|
125
|
-
isEnvDevelopment && !shouldUseReactRefresh
|
|
126
|
-
? [
|
|
127
|
-
// Include an alternative client for WebpackDevServer. A client's job is to
|
|
128
|
-
// connect to WebpackDevServer by a socket and get notified about changes.
|
|
129
|
-
// When you save a file, the client will either apply hot updates (in case
|
|
130
|
-
// of CSS changes), or refresh the page (in case of JS changes). When you
|
|
131
|
-
// make a syntax error, this client will display a syntax error overlay.
|
|
132
|
-
// Note: instead of the default WebpackDevServer client, we use a custom one
|
|
133
|
-
// to bring better experience for Create React App users. You can replace
|
|
134
|
-
// the line below with these two lines if you prefer the stock client:
|
|
135
|
-
//
|
|
136
|
-
// require.resolve('webpack-dev-server/client') + '?/',
|
|
137
|
-
// require.resolve('webpack/hot/dev-server'),
|
|
138
|
-
//
|
|
139
|
-
// When using the experimental react-refresh integration,
|
|
140
|
-
// the webpack plugin takes care of injecting the dev client for us.
|
|
141
|
-
webpackDevClientEntry,
|
|
142
|
-
// Finally, this is your app's code:
|
|
143
|
-
paths.appIndexJs,
|
|
144
|
-
// We include the app code last so that if there is a runtime error during
|
|
145
|
-
// initialization, it doesn't blow up the WebpackDevServer client, and
|
|
146
|
-
// changing JS code would still trigger a refresh.
|
|
147
|
-
]
|
|
148
|
-
: paths.appIndexJs,
|
|
167
|
+
entry: paths.appIndexJs,
|
|
149
168
|
output: {
|
|
150
169
|
// The build folder.
|
|
151
|
-
path:
|
|
170
|
+
path: paths.appBuild,
|
|
152
171
|
// Add /* filename */ comments to generated require()s in the output.
|
|
153
172
|
pathinfo: isEnvDevelopment,
|
|
154
173
|
// There will be one main bundle, and one file per asynchronous chunk.
|
|
155
174
|
// In development, it does not produce real files.
|
|
156
175
|
filename: isEnvDevelopment ? 'index.js' : process.env.FILENAME || 'index.js',
|
|
157
|
-
|
|
176
|
+
// There are also additional JS chunk files if you use code splitting.
|
|
177
|
+
chunkFilename: isEnvProduction
|
|
178
|
+
? 'static/js/[name].chunk.js'
|
|
179
|
+
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
|
180
|
+
assetModuleFilename: 'static/media/[name][ext]',
|
|
158
181
|
// webpack uses `publicPath` to determine where the app is being served from.
|
|
159
182
|
// It requires a trailing slash, or the file assets will get an incorrect path.
|
|
160
183
|
// We inferred the "public path" (such as / or /my-project) from homepage.
|
|
@@ -167,9 +190,22 @@ module.exports = function (webpackEnv) {
|
|
|
167
190
|
.replace(/\\/g, '/')
|
|
168
191
|
: isEnvDevelopment &&
|
|
169
192
|
(info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
193
|
+
},
|
|
194
|
+
cache: {
|
|
195
|
+
type: 'filesystem',
|
|
196
|
+
version: createEnvironmentHash(env.raw),
|
|
197
|
+
cacheDirectory: paths.appWebpackCache,
|
|
198
|
+
store: 'pack',
|
|
199
|
+
buildDependencies: {
|
|
200
|
+
defaultWebpack: ['webpack/lib/'],
|
|
201
|
+
config: [__filename],
|
|
202
|
+
tsconfig: [paths.appTsConfig, paths.appJsConfig].filter(f =>
|
|
203
|
+
fs.existsSync(f)
|
|
204
|
+
),
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
infrastructureLogging: {
|
|
208
|
+
level: 'none',
|
|
173
209
|
},
|
|
174
210
|
optimization: {
|
|
175
211
|
minimize: false,
|
|
@@ -249,9 +285,6 @@ module.exports = function (webpackEnv) {
|
|
|
249
285
|
...(modules.webpackAliases || {}),
|
|
250
286
|
},
|
|
251
287
|
plugins: [
|
|
252
|
-
// Adds support for installing with Plug'n'Play, leading to faster installs and adding
|
|
253
|
-
// guards against forgotten dependencies and such.
|
|
254
|
-
PnpWebpackPlugin,
|
|
255
288
|
// Prevents users from importing files from outside of src/ (or node_modules/).
|
|
256
289
|
// This often causes confusion because we only process files within src/ with babel.
|
|
257
290
|
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
|
@@ -259,20 +292,24 @@ module.exports = function (webpackEnv) {
|
|
|
259
292
|
// Make sure your source files are compiled, as they will not be processed in any way.
|
|
260
293
|
new ModuleScopePlugin(paths.appSrc, [
|
|
261
294
|
paths.appPackageJson,
|
|
262
|
-
|
|
295
|
+
reactRefreshRuntimeEntry,
|
|
296
|
+
reactRefreshWebpackPluginRuntimeEntry,
|
|
297
|
+
babelRuntimeEntry,
|
|
298
|
+
babelRuntimeEntryHelpers,
|
|
299
|
+
babelRuntimeRegenerator,
|
|
263
300
|
]),
|
|
264
301
|
],
|
|
265
302
|
},
|
|
266
|
-
resolveLoader: {
|
|
267
|
-
plugins: [
|
|
268
|
-
// Also related to Plug'n'Play, but this time it tells webpack to load its loaders
|
|
269
|
-
// from the current package.
|
|
270
|
-
PnpWebpackPlugin.moduleLoader(module),
|
|
271
|
-
],
|
|
272
|
-
},
|
|
273
303
|
module: {
|
|
274
304
|
strictExportPresence: true,
|
|
275
305
|
rules: [
|
|
306
|
+
// Handle node_modules packages that contain sourcemaps
|
|
307
|
+
shouldUseSourceMap && {
|
|
308
|
+
enforce: 'pre',
|
|
309
|
+
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
310
|
+
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
|
|
311
|
+
loader: require.resolve('source-map-loader'),
|
|
312
|
+
},
|
|
276
313
|
{
|
|
277
314
|
// "oneOf" will traverse all following loaders until one will
|
|
278
315
|
// match the requirements. When no loader matches it will fall
|
|
@@ -283,10 +320,11 @@ module.exports = function (webpackEnv) {
|
|
|
283
320
|
// A missing `test` is equivalent to a match.
|
|
284
321
|
{
|
|
285
322
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
323
|
+
type: 'asset',
|
|
324
|
+
parser: {
|
|
325
|
+
dataUrlCondition: {
|
|
326
|
+
maxSize: imageInlineSizeLimit,
|
|
327
|
+
},
|
|
290
328
|
},
|
|
291
329
|
},
|
|
292
330
|
// Process application JS with Babel.
|
|
@@ -304,7 +342,6 @@ module.exports = function (webpackEnv) {
|
|
|
304
342
|
require.resolve('babel-preset-react-app'),
|
|
305
343
|
{
|
|
306
344
|
runtime: modules.hasJsxRuntime ? 'automatic' : 'classic',
|
|
307
|
-
absoluteRuntime: false,
|
|
308
345
|
},
|
|
309
346
|
],
|
|
310
347
|
],
|
|
@@ -329,10 +366,6 @@ module.exports = function (webpackEnv) {
|
|
|
329
366
|
),
|
|
330
367
|
// @remove-on-eject-end
|
|
331
368
|
plugins: [
|
|
332
|
-
[
|
|
333
|
-
require.resolve('babel-plugin-named-asset-import'),
|
|
334
|
-
{ loaderMap: {} },
|
|
335
|
-
],
|
|
336
369
|
isEnvDevelopment &&
|
|
337
370
|
shouldUseReactRefresh &&
|
|
338
371
|
require.resolve('react-refresh/babel'),
|
|
@@ -400,6 +433,9 @@ module.exports = function (webpackEnv) {
|
|
|
400
433
|
sourceMap: isEnvProduction
|
|
401
434
|
? shouldUseSourceMap
|
|
402
435
|
: isEnvDevelopment,
|
|
436
|
+
modules: {
|
|
437
|
+
mode: 'icss',
|
|
438
|
+
},
|
|
403
439
|
}),
|
|
404
440
|
// Don't consider CSS imports dead code even if the
|
|
405
441
|
// containing package claims to have no side effects.
|
|
@@ -417,6 +453,7 @@ module.exports = function (webpackEnv) {
|
|
|
417
453
|
? shouldUseSourceMap
|
|
418
454
|
: isEnvDevelopment,
|
|
419
455
|
modules: {
|
|
456
|
+
mode: 'local',
|
|
420
457
|
getLocalIdent: getCSSModuleLocalIdent,
|
|
421
458
|
},
|
|
422
459
|
}),
|
|
@@ -433,6 +470,9 @@ module.exports = function (webpackEnv) {
|
|
|
433
470
|
sourceMap: isEnvProduction
|
|
434
471
|
? shouldUseSourceMap
|
|
435
472
|
: isEnvDevelopment,
|
|
473
|
+
modules: {
|
|
474
|
+
mode: 'icss',
|
|
475
|
+
},
|
|
436
476
|
},
|
|
437
477
|
'sass-loader'
|
|
438
478
|
),
|
|
@@ -453,6 +493,7 @@ module.exports = function (webpackEnv) {
|
|
|
453
493
|
? shouldUseSourceMap
|
|
454
494
|
: isEnvDevelopment,
|
|
455
495
|
modules: {
|
|
496
|
+
mode: 'local',
|
|
456
497
|
getLocalIdent: getCSSModuleLocalIdent,
|
|
457
498
|
},
|
|
458
499
|
},
|
|
@@ -464,35 +505,24 @@ module.exports = function (webpackEnv) {
|
|
|
464
505
|
test: /\.txt$/i,
|
|
465
506
|
use: 'raw-loader',
|
|
466
507
|
},
|
|
467
|
-
// svgr loader is disabled and SVGs are converted to PNG in React Unity
|
|
468
|
-
{
|
|
469
|
-
test: /\.svg$/i,
|
|
470
|
-
loader: 'svg-to-png-loader',
|
|
471
|
-
options: {
|
|
472
|
-
name: 'static/svg/[name]-[height]x[width].png',
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
508
|
// "file" loader makes sure those assets get served by WebpackDevServer.
|
|
476
509
|
// When you `import` an asset, you get its (virtual) filename.
|
|
477
510
|
// In production, they would get copied to the `build` folder.
|
|
478
511
|
// This loader doesn't use a "test" so it will catch all modules
|
|
479
512
|
// that fall through the other loaders.
|
|
480
513
|
{
|
|
481
|
-
loader: require.resolve('file-loader'),
|
|
482
514
|
// Exclude `js` files to keep "css" loader working as it injects
|
|
483
515
|
// its runtime that would otherwise be processed through "file" loader.
|
|
484
516
|
// Also exclude `json` extensions so they get processed
|
|
485
517
|
// by webpacks internal loaders.
|
|
486
|
-
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.json$/],
|
|
487
|
-
|
|
488
|
-
name: 'static/media/[name].[ext]',
|
|
489
|
-
},
|
|
518
|
+
exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx)$/, /\.json$/],
|
|
519
|
+
type: 'asset/resource',
|
|
490
520
|
},
|
|
491
521
|
// ** STOP ** Are you adding a new loader?
|
|
492
522
|
// Make sure to add the new loader(s) before the "file" loader.
|
|
493
523
|
],
|
|
494
524
|
},
|
|
495
|
-
],
|
|
525
|
+
].filter(Boolean),
|
|
496
526
|
},
|
|
497
527
|
plugins: [
|
|
498
528
|
// This gives some necessary context to module not found errors, such as
|
|
@@ -505,31 +535,48 @@ module.exports = function (webpackEnv) {
|
|
|
505
535
|
// Otherwise React will be compiled in the very slow development mode.
|
|
506
536
|
new webpack.DefinePlugin(env.stringified),
|
|
507
537
|
// Experimental hot reloading for React .
|
|
508
|
-
// https://github.com/facebook/react/tree/
|
|
538
|
+
// https://github.com/facebook/react/tree/main/packages/react-refresh
|
|
509
539
|
isEnvDevelopment &&
|
|
510
540
|
shouldUseReactRefresh &&
|
|
511
541
|
new ReactRefreshWebpackPlugin({
|
|
512
|
-
overlay:
|
|
513
|
-
entry: webpackDevClientEntry,
|
|
514
|
-
// The expected exports are slightly different from what the overlay exports,
|
|
515
|
-
// so an interop is included here to enable feedback on module-level errors.
|
|
516
|
-
module: reactRefreshOverlayEntry,
|
|
517
|
-
// Since we ship a custom dev client and overlay integration,
|
|
518
|
-
// the bundled socket handling logic can be eliminated.
|
|
519
|
-
sockIntegration: false,
|
|
520
|
-
},
|
|
542
|
+
overlay: false,
|
|
521
543
|
}),
|
|
522
544
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
523
545
|
// a plugin that prints an error when you attempt to do this.
|
|
524
546
|
// See https://github.com/facebook/create-react-app/issues/240
|
|
525
547
|
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
548
|
+
shouldExtractCss &&
|
|
549
|
+
new MiniCssExtractPlugin({
|
|
550
|
+
// Options similar to the same options in webpackOptions.output
|
|
551
|
+
// both options are optional
|
|
552
|
+
filename: 'static/css/[name].css',
|
|
553
|
+
chunkFilename: 'static/css/[name].chunk.css',
|
|
554
|
+
}),
|
|
555
|
+
// Generate an asset manifest file with the following content:
|
|
556
|
+
// - "files" key: Mapping of all asset filenames to their corresponding
|
|
557
|
+
// output file so that tools can pick it up without having to parse
|
|
558
|
+
// `index.html`
|
|
559
|
+
// - "entrypoints" key: Array of files which are included in `index.html`,
|
|
560
|
+
// can be used to reconstruct the HTML if necessary
|
|
561
|
+
generateManifest &&
|
|
562
|
+
new WebpackManifestPlugin({
|
|
563
|
+
fileName: 'asset-manifest.json',
|
|
564
|
+
publicPath: paths.publicUrlOrPath,
|
|
565
|
+
generate: (seed, files, entrypoints) => {
|
|
566
|
+
const manifestFiles = files.reduce((manifest, file) => {
|
|
567
|
+
manifest[file.name] = file.path;
|
|
568
|
+
return manifest;
|
|
569
|
+
}, seed);
|
|
570
|
+
const entrypointFiles = entrypoints.main.filter(
|
|
571
|
+
fileName => !fileName.endsWith('.map')
|
|
572
|
+
);
|
|
532
573
|
|
|
574
|
+
return {
|
|
575
|
+
files: manifestFiles,
|
|
576
|
+
entrypoints: entrypointFiles,
|
|
577
|
+
};
|
|
578
|
+
},
|
|
579
|
+
}),
|
|
533
580
|
// Moment.js is an extremely popular library that bundles large locale files
|
|
534
581
|
// by default due to how webpack interprets its code. This is a practical
|
|
535
582
|
// solution that requires the user to opt into importing specific locales.
|
|
@@ -543,36 +590,54 @@ module.exports = function (webpackEnv) {
|
|
|
543
590
|
// TypeScript type checking
|
|
544
591
|
useTypeScript &&
|
|
545
592
|
new ForkTsCheckerWebpackPlugin({
|
|
546
|
-
typescript: resolve.sync('typescript', {
|
|
547
|
-
basedir: paths.appNodeModules,
|
|
548
|
-
}),
|
|
549
593
|
async: isEnvDevelopment,
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
594
|
+
typescript: {
|
|
595
|
+
typescriptPath: resolve.sync('typescript', {
|
|
596
|
+
basedir: paths.appNodeModules,
|
|
597
|
+
}),
|
|
598
|
+
configOverwrite: {
|
|
599
|
+
compilerOptions: {
|
|
600
|
+
sourceMap: isEnvProduction
|
|
601
|
+
? shouldUseSourceMap
|
|
602
|
+
: isEnvDevelopment,
|
|
603
|
+
skipLibCheck: true,
|
|
604
|
+
inlineSourceMap: false,
|
|
605
|
+
declarationMap: false,
|
|
606
|
+
noEmit: true,
|
|
607
|
+
incremental: true,
|
|
608
|
+
tsBuildInfoFile: paths.appTsBuildInfoFile,
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
context: paths.appPath,
|
|
612
|
+
diagnosticOptions: {
|
|
613
|
+
syntactic: true,
|
|
614
|
+
},
|
|
615
|
+
mode: 'write-references',
|
|
616
|
+
// profile: true,
|
|
617
|
+
},
|
|
618
|
+
issue: {
|
|
559
619
|
// This one is specifically to match during CI tests,
|
|
560
620
|
// as micromatch doesn't match
|
|
561
621
|
// '../cra-template-typescript/template/src/App.tsx'
|
|
562
622
|
// otherwise.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
623
|
+
include: [
|
|
624
|
+
{ file: '../**/src/**/*.{ts,tsx}' },
|
|
625
|
+
{ file: '**/src/**/*.{ts,tsx}' },
|
|
626
|
+
],
|
|
627
|
+
exclude: [
|
|
628
|
+
{ file: '**/src/**/__tests__/**' },
|
|
629
|
+
{ file: '**/src/**/?(*.){spec|test}.*' },
|
|
630
|
+
{ file: '**/src/setupProxy.*' },
|
|
631
|
+
{ file: '**/src/setupTests.*' },
|
|
632
|
+
],
|
|
633
|
+
},
|
|
634
|
+
logger: {
|
|
635
|
+
infrastructure: 'silent',
|
|
636
|
+
},
|
|
573
637
|
}),
|
|
574
638
|
!disableESLintPlugin &&
|
|
575
639
|
new ESLintPlugin({
|
|
640
|
+
// Plugin options
|
|
576
641
|
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
|
577
642
|
eslintPath: require.resolve('eslint'),
|
|
578
643
|
failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
|