feat: добавить серверную генерацию спрайтов

This commit is contained in:
2026-07-16 09:14:11 +03:00
parent e9ae91815a
commit 57342fae4e
379 changed files with 3108 additions and 655 deletions

View File

@@ -3,7 +3,9 @@
"private": true,
"version": "0.0.0",
"scripts": {
"sprites": "svg-sprites src/sprite/svg-sprite.config.ts",
"sprites": "npm run sprites:local && npm run sprites:remote",
"sprites:local": "svg-sprites src/app-icons/svg-sprite.config.ts",
"sprites:remote": "svg-sprites src/remote-app-icons/svg-sprite.config.js",
"typecheck": "tsc --noEmit",
"build": "npm run sprites && next build --turbopack",
"dev": "npm run sprites && next dev --turbopack",

View File

@@ -1,15 +1,17 @@
import { SpriteViewer } from '@gromlab/svg-sprites/react'
import { IconsIcon } from '../src/sprite'
import { AppIcon } from '../src/app-icons'
import { RemoteAppIcon } from '../src/remote-app-icons'
const viewerSources = [
() => import('../src/sprite/.svg-sprite/svg-sprite.manifest.js'),
() => import('../src/app-icons/.svg-sprite/svg-sprite.manifest.js'),
() => import('../src/remote-app-icons/.svg-sprite/svg-sprite.manifest.js'),
] as const
export default function Page() {
return (
<main>
<h1>Next.js Pages Router + Turbopack</h1>
<IconsIcon
<AppIcon
data-testid="icon"
data-app="next-pages-turbopack"
icon="check"
@@ -18,6 +20,15 @@ export default function Page() {
height={64}
style={{ '--icon-color-1': '#16a34a' }}
/>
<RemoteAppIcon
data-testid="remote-icon"
data-app="next-pages-turbopack-remote"
icon="check"
aria-label="Remote check icon"
width={64}
height={64}
style={{ '--icon-color-1': '#16a34a' }}
/>
<SpriteViewer sources={viewerSources} title="Next Pages Turbopack Viewer" style={{ marginTop: 32 }} />
</main>
)

View File

@@ -2,7 +2,7 @@ import { defineSpriteConfig } from '@gromlab/svg-sprites'
export default defineSpriteConfig({
mode: 'next@pages/turbopack',
name: 'icons',
name: 'app',
input: '../../../../fixtures/icons/check.svg',
generatedNotice: false,
})

View File

@@ -0,0 +1,2 @@
# @generated by @gromlab/svg-sprites. Do not edit.
/.svg-sprite/

View File

@@ -0,0 +1 @@
export * from './.svg-sprite'

View File

@@ -0,0 +1,6 @@
export default {
mode: 'next@pages/turbopack',
source: 'remote',
input: process.env.SVG_SPRITE_REMOTE_MANIFEST_URL
?? '../../../standalone-server/cases/mixed-input/.svg-sprite/svg-sprite.manifest.json',
}