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.json --noEmit",
|
||||
"build": "npm run sprites && webpack --mode production",
|
||||
"dev": "npm run sprites && webpack serve --mode development"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default {
|
||||
mode: 'angular@webpack',
|
||||
name: 'icons',
|
||||
name: 'app',
|
||||
input: '../../../../fixtures/icons/check.svg',
|
||||
generatedNotice: false,
|
||||
}
|
||||
@@ -3,24 +3,32 @@ import '@gromlab/svg-sprites/viewer/element'
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core'
|
||||
import { bootstrapApplication } from '@angular/platform-browser'
|
||||
|
||||
import { IconsIcon } from './sprite'
|
||||
import { AppIcon } from './app-icons'
|
||||
import { RemoteAppIcon } from './remote-app-icons'
|
||||
import './type-probe'
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [IconsIcon],
|
||||
imports: [AppIcon, RemoteAppIcon],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
template: `
|
||||
<main>
|
||||
<h1>Angular + Webpack</h1>
|
||||
<icons-icon
|
||||
<app-icon
|
||||
data-testid="icon"
|
||||
data-app="angular-webpack"
|
||||
icon="check"
|
||||
aria-label="Check icon"
|
||||
style="width:64px;height:64px;color:#16a34a;--icon-color-1:#16a34a"
|
||||
/>
|
||||
<remote-app-icon
|
||||
data-testid="remote-icon"
|
||||
data-app="angular-webpack-remote"
|
||||
icon="check"
|
||||
aria-label="Remote check icon"
|
||||
style="width:64px;height:64px;color:#16a34a;--icon-color-1:#16a34a"
|
||||
/>
|
||||
<gromlab-sprite-viewer
|
||||
[sources]="viewerSources"
|
||||
viewer-title="Angular Webpack Viewer"
|
||||
@@ -30,7 +38,8 @@ import './type-probe'
|
||||
})
|
||||
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-webpack/src/remote-app-icons/.gitignore
vendored
Normal file
2
integration/apps/angular-webpack/src/remote-app-icons/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# @generated by @gromlab/svg-sprites. Do not edit.
|
||||
/.svg-sprite/
|
||||
@@ -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@webpack',
|
||||
source: 'remote',
|
||||
input: manifestUrl,
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
import type { IconsIconName } from './sprite'
|
||||
import type { AppIconName } from './app-icons'
|
||||
import type { RemoteAppIconName } from './remote-app-icons'
|
||||
|
||||
const validIcon: IconsIconName = 'check'
|
||||
const validIcon: AppIconName = 'check'
|
||||
const validRemoteIcon: RemoteAppIconName = 'check'
|
||||
void validIcon
|
||||
void validRemoteIcon
|
||||
|
||||
// @ts-expect-error generated icon names are a closed union
|
||||
const invalidIcon: IconsIconName = 'missing'
|
||||
const invalidIcon: AppIconName = 'missing'
|
||||
void invalidIcon
|
||||
|
||||
Reference in New Issue
Block a user