manual-chunked

This commit is contained in:
Untone 2024-09-03 18:37:57 +03:00
parent 6bfaa3fb51
commit 7fa17cee3c
5 changed files with 30 additions and 17 deletions

View File

@ -34,11 +34,6 @@ export default defineConfig({
https: true
},
devOverlay: true,
build: {
chunkSizeWarningLimit: 1024,
target: 'esnext',
sourcemap: true
},
vite: {
envPrefix: 'PUBLIC_',
plugins: [!isVercel && mkcert(), nodePolyfills(polyfillOptions), sassDts()],
@ -49,6 +44,23 @@ export default defineConfig({
includePaths: ['./public', './src/styles']
}
} as CSSOptions['preprocessorOptions']
},
build: {
chunkSizeWarningLimit: 800,
target: 'esnext',
sourcemap: true,
rollupOptions: {
// plugins: [visualizer()]
output: {
manualChunks: {
'icons': ['./src/components/_shared/Icon/Icon.tsx'],
'session': ['./src/context/session.tsx'],
'editor': ['./src/context/editor.tsx'],
'localize': ['./src/context/localize.tsx'],
'connect': ['./src/context/connect.tsx']
}
}
}
}
}
} as SolidStartInlineConfig)

View File

@ -182,19 +182,25 @@ export const AuthorView = (props: AuthorViewProps) => {
})
const result = await authorCommentsFetcher()
result && addReactions(result)
result && setCommented((prev) => [...new Set([...(prev || []), ...result])])
restoreScrollPosition()
return result as LoadMoreItems
}
createEffect(() => setCurrentTab(params.tab))
createEffect(
on(
[author, commented],
([a, ccc]) => a && setLoadMoreCommentsHidden(ccc?.length === a.stat?.comments),
[author, commentsByAuthor],
([a, ccc]) => {
if (a && ccc && ccc[a.id]) {
setCommented(ccc[a.id])
setLoadMoreCommentsHidden(ccc[a.id]?.length === a.stat?.comments)
}
},
{}
)
)
createEffect(
on(
[author, feedByAuthor],

View File

@ -49,10 +49,7 @@ export const LoadMoreWrapper = (props: LoadMoreProps) => {
restoreScrollPosition()
}
onMount(() => {
loadItems()
console.debug(`load on mount ${items()}`)
})
onMount(loadItems)
return (
<>

View File

@ -4,8 +4,6 @@ import ICU from 'i18next-icu'
import TimeAgo from 'javascript-time-ago'
import enTime from 'javascript-time-ago/locale/en'
import ruTime from 'javascript-time-ago/locale/ru'
import en from '~/intl/locales/en/translation.json'
import ru from '~/intl/locales/ru/translation.json'
TimeAgo.addLocale(enTime)
TimeAgo.addLocale(ruTime)
@ -13,7 +11,8 @@ TimeAgo.addLocale(ruTime)
export const i18nextInit = async (lng = 'ru') => {
if (!i18next.isInitialized) {
console.debug('[i18next] initializing...')
const en = await import('~/intl/locales/en/translation.json')
const ru = await import('~/intl/locales/ru/translation.json')
await i18next
.use(HttpApi)
.use(ICU)

View File

@ -1,7 +1,6 @@
import { RouteSectionProps, createAsync, useSearchParams } from '@solidjs/router'
import { Client } from '@urql/core'
import { createEffect, createMemo } from 'solid-js'
import { AUTHORS_PER_PAGE } from '~/components/Views/AllAuthors/AllAuthors'
import { Feed } from '~/components/Views/Feed'
import { FeedProps } from '~/components/Views/Feed/Feed'
import { LoadMoreItems, LoadMoreWrapper } from '~/components/_shared/LoadMoreWrapper'
@ -125,7 +124,7 @@ export default (props: RouteSectionProps<{ shouts: Shout[]; topics: Topic[] }>)
key="feed"
desc="Independent media project about culture, science, art and society with horizontal editing"
>
<LoadMoreWrapper loadFunction={loadMoreFeed} pageSize={AUTHORS_PER_PAGE}>
<LoadMoreWrapper loadFunction={loadMoreFeed} pageSize={SHOUTS_PER_PAGE}>
<ReactionsProvider>
<Feed shouts={feed() || (shouts() as Shout[])} order={order() as FeedProps['order']} />
</ReactionsProvider>