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

@@ -1,11 +1,12 @@
<script setup>
import { IconsIcon } from '../src/sprite/index.js'
import { AppIcon } from '../src/app-icons/index.js'
import { RemoteAppIcon } from '../src/remote-app-icons/index.js'
</script>
<template>
<main>
<h1>Nuxt + Vite</h1>
<IconsIcon
<AppIcon
data-testid="icon"
data-app="nuxt-vite"
icon="check"
@@ -14,6 +15,15 @@ import { IconsIcon } from '../src/sprite/index.js'
height="64"
style="--icon-color-1: #16a34a"
/>
<RemoteAppIcon
data-testid="remote-icon"
data-app="nuxt-vite-remote"
icon="check"
aria-label="Remote check icon"
width="64"
height="64"
style="--icon-color-1: #16a34a"
/>
<SpriteViewer />
</main>
</template>

View File

@@ -4,7 +4,8 @@ import { defineSpriteViewerElement } from '@gromlab/svg-sprites/viewer'
defineSpriteViewerElement()
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'),
]
</script>

View File

@@ -1,15 +1,30 @@
import { IconsIcon } from '../src/sprite/.svg-sprite/index.js'
import type { IconsIconName, IconsIconProps } from '../src/sprite/.svg-sprite/index.js'
import { AppIcon } from '../src/app-icons/.svg-sprite/index.js'
import type { AppIconName, AppIconProps } from '../src/app-icons/.svg-sprite/index.js'
import { RemoteAppIcon } from '../src/remote-app-icons/.svg-sprite/index.js'
import type {
RemoteAppIconName,
RemoteAppIconProps,
} from '../src/remote-app-icons/.svg-sprite/index.js'
const iconName: IconsIconName = 'check'
const iconProps: IconsIconProps = {
const iconName: AppIconName = 'check'
const iconProps: AppIconProps = {
icon: iconName,
width: 64,
style: { '--icon-color-1': '#16a34a' },
}
const remoteIconName: RemoteAppIconName = 'check'
const remoteIconProps: RemoteAppIconProps = {
icon: remoteIconName,
width: 64,
style: { '--icon-color-1': '#16a34a' },
}
void [IconsIcon, iconProps]
void [AppIcon, RemoteAppIcon, iconProps, remoteIconProps]
// @ts-expect-error Generated icon names form a literal union.
const missingIcon: IconsIconName = 'missing'
const missingIcon: AppIconName = 'missing'
void missingIcon
// @ts-expect-error Generated remote icon names form a literal union.
const missingRemoteIcon: RemoteAppIconName = 'missing'
void missingRemoteIcon

View File

@@ -4,7 +4,9 @@
"version": "0.0.0",
"type": "module",
"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": "nuxt typecheck",
"build": "npm run sprites && nuxt build",
"dev": "npm run sprites && nuxt dev",

View File

@@ -2,7 +2,7 @@ import { defineSpriteConfig } from '@gromlab/svg-sprites'
export default defineSpriteConfig({
mode: 'nuxt@vite',
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/index.js'

View File

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

View File

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