mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
43 lines
1.6 KiB
HTML
43 lines
1.6 KiB
HTML
{% capture entry %}{% if page.layout and layout.jsEntry %}{{ layout.jsEntry }}{% elsif page.jsEntry %}{{ page.jsEntry }}{% else %}default{% endif %}{% endcapture %}
|
|
{% vite_typescript_tag {{ entry }} %}
|
|
<script nomodule>
|
|
(function() {
|
|
var check = document.createElement('script');
|
|
if (!('noModule' in check) && 'onbeforeload' in check) {
|
|
var support = false;
|
|
document.addEventListener('beforeload', function(e) {
|
|
if (e.target === check) {
|
|
support = true;
|
|
} else if (!e.target.hasAttribute('nomodule') || !support) {
|
|
return;
|
|
}
|
|
e.preventDefault();
|
|
}, true);
|
|
|
|
check.type = 'module';
|
|
check.src = '.';
|
|
document.head.appendChild(check);
|
|
check.remove();
|
|
}
|
|
}());
|
|
</script>
|
|
<script src="{% vite_asset_path /vite/legacy-polyfills-legacy %}" crossorigin="anonymous" id="vite-legacy-polyfill" nomodule></script>
|
|
{% capture legacyFile %}{% vite_asset_path {{ entry }}-legacy.ts %}{% endcapture %}
|
|
<script nomodule defer>System.import({{ legacyFile | jsonify }});</script>
|
|
<script dummytype="application/javascript" type="module">
|
|
(function(){
|
|
try{
|
|
new Function("m","return import(m)");
|
|
}catch(e){
|
|
console.warn("vite: loading legacy build because dynamic import is unsupported, syntax error above should be ignored");
|
|
var polyScript = document.getElementById("vite-legacy-polyfill");
|
|
var newScript = document.createElement("script");
|
|
newScript.src = polyScript.src;
|
|
newScript.onload = function(){
|
|
System.import({{ legacyFile | jsonify }});
|
|
};
|
|
document.body.appendChild(newScript);
|
|
}
|
|
})();
|
|
</script>
|