Inject vendor.js via loader
This commit is contained in:
parent
94aaa6e10c
commit
07788b4e5e
9 changed files with 17 additions and 21 deletions
|
@ -10,7 +10,7 @@ export default {
|
|||
const { href } = item;
|
||||
return fetch(href, options)
|
||||
.then((res) => res.text())
|
||||
.then((text) => ({ type: 'application/javascript', text }))
|
||||
.then((text) => ({ type: 'application/javascript', text, ...item.props }))
|
||||
.then((props) => Object.assign(document.createElement('script'), props));
|
||||
},
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<%= erb("_favicon.html.erb") %>
|
||||
</head>
|
||||
<body>
|
||||
<script src="/js/main/vendor.js?v=<%= commit %>"></script>
|
||||
<script src="/js/main/random.js?v=<%= commit %>"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
<%= erb("_favicon.html.erb") %>
|
||||
</head>
|
||||
<body>
|
||||
<script src="/js/main/vendor.js?v=<%= commit %>"></script>
|
||||
<script src="/js/main/redirect.js?v=<%= commit %>"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<body>
|
||||
<%= erb("_postman.html.erb", {locale: context.locale, dir: context.dir}) %>
|
||||
<div class="root h-full"></div>
|
||||
<script src="/js/main/vendor.js?v=<%= commit %>"></script>
|
||||
<script src="/js/loaders/surah-index-loader.js?v=<%= commit %>"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
data-surah-id="<%= context.surah.id %>"
|
||||
data-audio-base-url="<%= audio_base_url %>">
|
||||
</div>
|
||||
<script src="/js/main/vendor.js?v=<%= commit %>"></script>
|
||||
<script src="/js/loaders/surah-stream-loader.js?v=<%= commit %>"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -18,7 +18,8 @@ import { formatNumber } from "~/lib/t";
|
|||
const progressBar: HTMLProgressElement = loader.querySelector("progress")!;
|
||||
const progressNumber: HTMLSpanElement = loader.querySelector(".percentage")!;
|
||||
postman(
|
||||
item.script(`/js/main/surah-index.js?v=${rev}`),
|
||||
item.script(`/js/main/vendor.js?v=${rev}`, { id: 0 }),
|
||||
item.script(`/js/main/surah-index.js?v=${rev}`, { id: 1 }),
|
||||
item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"),
|
||||
item.font("Mada Regular", "url(/fonts/mada-regular.ttf"),
|
||||
item.progress((percent: number) => {
|
||||
|
@ -34,8 +35,10 @@ import { formatNumber } from "~/lib/t";
|
|||
[loader, style].forEach((el) => el.remove());
|
||||
pkg.fonts.forEach((f) => document.fonts.add(f));
|
||||
pkg.css.forEach((s) => document.head.appendChild(s));
|
||||
pkg.scripts.forEach((s) =>
|
||||
document.body.removeChild(document.body.appendChild(s)),
|
||||
);
|
||||
pkg.scripts
|
||||
.sort((s) => s.id)
|
||||
.forEach((s) => {
|
||||
document.body.removeChild(document.body.appendChild(s));
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -19,7 +19,8 @@ import { formatNumber } from "~/lib/t";
|
|||
const progressBar = loader.querySelector("progress")!;
|
||||
const progressNumber: HTMLSpanElement = loader.querySelector(".percentage")!;
|
||||
postman(
|
||||
item.script(`/js/main/surah-stream.js?v=${rev}`),
|
||||
item.script(`/js/main/vendor.js?v=${rev}`, { id: 0 }),
|
||||
item.script(`/js/main/surah-stream.js?v=${rev}`, { id: 1 }),
|
||||
item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"),
|
||||
item.font("Mada Regular", "url(/fonts/mada-regular.ttf"),
|
||||
/* eslint-disable */
|
||||
|
@ -41,8 +42,10 @@ import { formatNumber } from "~/lib/t";
|
|||
pkg.fonts.forEach((f) => document.fonts.add(f));
|
||||
pkg.css.forEach((s) => document.head.appendChild(s));
|
||||
pkg.json.forEach((o) => document.body.appendChild(o));
|
||||
pkg.scripts.forEach((s) =>
|
||||
document.body.removeChild(document.body.appendChild(s)),
|
||||
);
|
||||
pkg.scripts
|
||||
.sort((s) => s.id)
|
||||
.forEach((s) => {
|
||||
document.body.removeChild(document.body.appendChild(s));
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -14,8 +14,5 @@ import { SurahIndex } from "~/components/SurahIndex";
|
|||
(e: TSurah) => new Surah(e),
|
||||
);
|
||||
|
||||
render(
|
||||
<SurahIndex locale={locale} surahs={surahs} t={t} />,
|
||||
root
|
||||
);
|
||||
render(<SurahIndex locale={locale} surahs={surahs} t={t} />, root);
|
||||
})();
|
||||
|
|
|
@ -30,8 +30,5 @@ import { SurahStream } from "~/components/SurahStream";
|
|||
ayah.ms = ms * 1000;
|
||||
}
|
||||
|
||||
render(
|
||||
<SurahStream surah={surah} locale={locale} t={t} />,
|
||||
root
|
||||
);
|
||||
render(<SurahStream surah={surah} locale={locale} t={t} />, root);
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue