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

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

View File

@@ -1,13 +1,20 @@
import { IconsIcon, iconsIconNames } from './sprite/index.js'
import type { IconsIconName, IconsIconProps } from './sprite/index.js'
import { AppIcon, appIconNames } from './app-icons/index.js'
import type { AppIconName, AppIconProps } from './app-icons/index.js'
import { RemoteAppIcon, remoteAppIconNames } from './remote-app-icons/index.js'
import type { RemoteAppIconName, RemoteAppIconProps } from './remote-app-icons/index.js'
const iconName: IconsIconName = 'check'
const props: IconsIconProps = { icon: iconName, width: 24 }
const appIconName: AppIconName = 'check'
const appProps: AppIconProps = { icon: appIconName, width: 24 }
const remoteAppIconName: RemoteAppIconName = 'check'
const remoteAppProps: RemoteAppIconProps = { icon: remoteAppIconName, width: 24 }
void IconsIcon
void iconsIconNames
void props
void AppIcon
void appIconNames
void appProps
void RemoteAppIcon
void remoteAppIconNames
void remoteAppProps
// @ts-expect-error Generated icon names form a literal union.
const missingIcon: IconsIconName = 'missing'
const missingIcon: AppIconName = 'missing'
void missingIcon

View File

@@ -1,11 +1,13 @@
import { h, render } from 'preact'
import '@gromlab/svg-sprites/viewer/element'
import { IconsIcon } from './sprite/index.js'
import { AppIcon } from './app-icons/index.js'
import { RemoteAppIcon } from './remote-app-icons/index.js'
import './style.css'
const viewerSources = [
() => import('./sprite/.svg-sprite/svg-sprite.manifest.js'),
() => import('./app-icons/.svg-sprite/svg-sprite.manifest.js'),
() => import('./remote-app-icons/.svg-sprite/svg-sprite.manifest.js'),
]
function App() {
@@ -15,7 +17,7 @@ function App() {
return h('main', null,
h('h1', null, 'Preact + Webpack'),
h(IconsIcon, {
h(AppIcon, {
'data-testid': 'icon',
'data-app': 'preact-webpack',
icon: 'check',
@@ -24,6 +26,15 @@ function App() {
height: 64,
style: { '--icon-color-1': '#16a34a' },
}),
h(RemoteAppIcon, {
'data-testid': 'remote-icon',
'data-app': 'preact-webpack-remote',
icon: 'check',
'aria-label': 'Remote check icon',
width: 64,
height: 64,
style: { '--icon-color-1': '#16a34a' },
}),
h('gromlab-sprite-viewer', {
ref: connectViewer,
'viewer-title': 'Preact Webpack Viewer',

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/index.js'

View File

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

View File

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