mirror of
https://github.com/gromlab-ru/svg-sprites.git
synced 2026-07-22 04:40:17 +03:00
feat: добавить серверную генерацию спрайтов
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default {
|
||||
mode: 'angular@application',
|
||||
name: 'icons',
|
||||
name: 'app',
|
||||
input: '../../../../fixtures/icons/check.svg',
|
||||
generatedNotice: false,
|
||||
}
|
||||
@@ -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'),
|
||||
]
|
||||
}
|
||||
|
||||
2
integration/apps/angular/src/remote-app-icons/.gitignore
vendored
Normal file
2
integration/apps/angular/src/remote-app-icons/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# @generated by @gromlab/svg-sprites. Do not edit.
|
||||
/.svg-sprite/
|
||||
1
integration/apps/angular/src/remote-app-icons/index.ts
Normal file
1
integration/apps/angular/src/remote-app-icons/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './.svg-sprite/index'
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user