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": "ngc -p tsconfig.app.json --noEmit",
"build": "npm run sprites && ng build --configuration production",
"dev": "npm run sprites && ng serve"

View File

@@ -1,6 +1,6 @@
export default {
mode: 'angular@application',
name: 'icons',
name: 'app',
input: '../../../../fixtures/icons/check.svg',
generatedNotice: false,
}

View File

@@ -2,22 +2,30 @@ import '@gromlab/svg-sprites/viewer/element'
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core'
import { IconsIcon } from './sprite'
import { AppIcon } from './app-icons'
import { RemoteAppIcon } from './remote-app-icons'
@Component({
selector: 'app-root',
standalone: true,
imports: [IconsIcon],
imports: [AppIcon, RemoteAppIcon],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<main>
<h1>Angular application builder</h1>
<icons-icon
<app-icon
data-testid="icon"
data-app="angular"
icon="check"
aria-label="Check icon"
style="color: #16a34a; --icon-color-1: #16a34a"
style="width:64px;height:64px;color:#16a34a;--icon-color-1:#16a34a"
/>
<remote-app-icon
data-testid="remote-icon"
data-app="angular-remote"
icon="check"
aria-label="Remote check icon"
style="width:64px;height:64px;color:#16a34a;--icon-color-1:#16a34a"
/>
<gromlab-sprite-viewer
[sources]="viewerSources"
@@ -28,6 +36,7 @@ import { IconsIcon } from './sprite'
})
export class AppComponent {
readonly 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'),
]
}

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'

View File

@@ -0,0 +1,8 @@
const manifestUrl = process.env.SVG_SPRITE_REMOTE_MANIFEST_URL
?? '../../../standalone-server/cases/mixed-input/.svg-sprite/svg-sprite.manifest.json'
export default {
mode: 'angular@application',
source: 'remote',
input: manifestUrl,
}

View File

@@ -9,7 +9,8 @@ body {
padding: 40px;
}
icons-icon[data-testid='icon'] {
app-icon[data-testid='icon'],
remote-app-icon[data-testid='remote-icon'] {
width: 64px;
height: 64px;
color: #16a34a;

View File

@@ -1,10 +1,14 @@
import type { IconsIconName } from './sprite'
import type { SpriteManifest } from './sprite/.svg-sprite/svg-sprite.manifest.js'
import type { AppIconName } from './app-icons'
import type { SpriteManifest as AppSpriteManifest } from './app-icons/.svg-sprite/svg-sprite.manifest.js'
import type { RemoteAppIconName } from './remote-app-icons'
import type { SpriteManifest as RemoteAppSpriteManifest } from './remote-app-icons/.svg-sprite/svg-sprite.manifest.js'
const icon: IconsIconName = 'check'
const mode: SpriteManifest['mode'] = 'angular@application'
const icon: AppIconName = 'check'
const remoteIcon: RemoteAppIconName = 'check'
const mode: AppSpriteManifest['mode'] = 'angular@application'
const remoteMode: RemoteAppSpriteManifest['mode'] = 'angular@application'
// @ts-expect-error Unknown source file names are rejected by the generated union.
const unknownIcon: IconsIconName = 'missing'
const unknownIcon: AppIconName = 'missing'
export { icon, mode, unknownIcon }
export { icon, mode, remoteIcon, remoteMode, unknownIcon }