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

@@ -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": "vue-tsc --noEmit",
"build": "npm run sprites && vue-tsc --noEmit && webpack --mode production",
"dev": "npm run sprites && webpack serve --mode development"

View File

@@ -1,17 +1,19 @@
<script setup>
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'
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'),
]
</script>
<template>
<main>
<h1>Vue + Webpack</h1>
<IconsIcon
<AppIcon
data-testid="icon"
data-app="vue-webpack"
icon="check"
@@ -20,6 +22,15 @@ const viewerSources = [
height="64"
style="--icon-color-1: #16a34a"
/>
<RemoteAppIcon
data-testid="remote-icon"
data-app="vue-webpack-remote"
icon="check"
aria-label="Remote check icon"
width="64"
height="64"
style="--icon-color-1: #16a34a"
/>
<gromlab-sprite-viewer
:sources="viewerSources"
viewer-title="Vue Webpack Viewer"

View File

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

View File

@@ -1,15 +1,30 @@
import { IconsIcon } from './sprite/.svg-sprite/index.js'
import type { IconsIconName, IconsIconProps } from './sprite/.svg-sprite/index.js'
import { AppIcon } from './app-icons/.svg-sprite/index.js'
import type { AppIconName, AppIconProps } from './app-icons/.svg-sprite/index.js'
import { RemoteAppIcon } from './remote-app-icons/.svg-sprite/index.js'
import type {
RemoteAppIconName,
RemoteAppIconProps,
} from './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

@@ -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: 'vue@webpack',
source: 'remote',
input: process.env.SVG_SPRITE_REMOTE_MANIFEST_URL
?? '../../../standalone-server/cases/mixed-input/.svg-sprite/svg-sprite.manifest.json',
}