mirror of
https://github.com/zoriya/flood.git
synced 2026-06-04 19:36:42 +00:00
client: add chunk names to async imports
This commit is contained in:
@@ -17,7 +17,7 @@ import '../sass/style.scss';
|
||||
const Login = React.lazy(() => import(/* webpackPrefetch: true */ './components/views/Login'));
|
||||
const Register = React.lazy(() => import(/* webpackPrefetch: true */ './components/views/Register'));
|
||||
const TorrentClientOverview = React.lazy(
|
||||
() => import(/* webpackPrefetch: true */ './components/views/TorrentClientOverview'),
|
||||
() => import(/* webpackPreload: true */ './components/views/TorrentClientOverview'),
|
||||
);
|
||||
|
||||
const initialize = async (): Promise<void> => {
|
||||
|
||||
@@ -13,7 +13,7 @@ const getFlag = (countryCode?: string): string | null => {
|
||||
|
||||
const loadFlag = async () => {
|
||||
let flag: string | null = null;
|
||||
await import(`../../../images/flags/${countryCode.toLowerCase()}.png`)
|
||||
await import(/* webpackChunkName: 'flag' */ `../../../images/flags/${countryCode.toLowerCase()}.png`)
|
||||
.then(
|
||||
({default: image}: {default: string}) => {
|
||||
flag = image;
|
||||
|
||||
@@ -3,7 +3,7 @@ import React from 'react';
|
||||
import {version} from '../../../../../../package.json';
|
||||
|
||||
const AboutMarkdown = React.lazy(() =>
|
||||
import('../../../../../../ABOUT.md').then((module) => ({default: module.react})),
|
||||
import(/* webpackChunkName: 'about' */ '../../../../../../ABOUT.md').then((module) => ({default: module.react})),
|
||||
);
|
||||
|
||||
const FLOOD_PROJECT_URL = 'https://github.com/jesec/flood';
|
||||
|
||||
@@ -28,12 +28,13 @@ function loadTranslator() {
|
||||
|
||||
async function loadMessages(locale: Exclude<Language, 'auto'>) {
|
||||
const messages: Record<string, MessageFormatElement[]> = await import(
|
||||
/* webpackChunkName: 'i18n' */
|
||||
`./compiled/${locale === 'translate' ? 'en' : locale}.json`
|
||||
);
|
||||
messagesCache[locale] = messages;
|
||||
|
||||
if (locale !== 'translate') {
|
||||
await import(`dayjs/locale/${dayjsLocale}.js`);
|
||||
await import(/* webpackChunkName: 'i18n' */ `dayjs/locale/${dayjsLocale}.js`);
|
||||
}
|
||||
|
||||
return messages;
|
||||
|
||||
Reference in New Issue
Block a user