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:
@@ -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": "tsc --noEmit",
|
||||
"build": "npm run sprites && npm run typecheck && webpack --mode production",
|
||||
"dev": "npm run sprites && webpack serve --mode development"
|
||||
|
||||
@@ -2,7 +2,7 @@ import { defineSpriteConfig } from '@gromlab/svg-sprites'
|
||||
|
||||
export default defineSpriteConfig({
|
||||
mode: 'solid@webpack',
|
||||
name: 'icons',
|
||||
name: 'app',
|
||||
input: '../../../../fixtures/icons/check.svg',
|
||||
generatedNotice: false,
|
||||
})
|
||||
@@ -1,13 +1,20 @@
|
||||
import { IconsIcon, iconsIconNames } from './sprite/index.js'
|
||||
import type { IconsIconName, IconsIconProps } from './sprite/index.js'
|
||||
import { AppIcon, appIconNames } from './app-icons/index.js'
|
||||
import type { AppIconName, AppIconProps } from './app-icons/index.js'
|
||||
import { RemoteAppIcon, remoteAppIconNames } from './remote-app-icons/index.js'
|
||||
import type { RemoteAppIconName, RemoteAppIconProps } from './remote-app-icons/index.js'
|
||||
|
||||
const iconName: IconsIconName = 'check'
|
||||
const props: IconsIconProps = { icon: iconName, width: 24 }
|
||||
const iconName: AppIconName = 'check'
|
||||
const remoteIconName: RemoteAppIconName = 'check'
|
||||
const props: AppIconProps = { icon: iconName, width: 24 }
|
||||
const remoteProps: RemoteAppIconProps = { icon: remoteIconName, width: 24 }
|
||||
|
||||
void IconsIcon
|
||||
void iconsIconNames
|
||||
void AppIcon
|
||||
void appIconNames
|
||||
void RemoteAppIcon
|
||||
void remoteAppIconNames
|
||||
void props
|
||||
void remoteProps
|
||||
|
||||
// @ts-expect-error Generated icon names form a literal union.
|
||||
const missingIcon: IconsIconName = 'missing'
|
||||
const missingIcon: AppIconName = 'missing'
|
||||
void missingIcon
|
||||
|
||||
@@ -2,11 +2,13 @@ import { onMount } from 'solid-js'
|
||||
import { render } from 'solid-js/web'
|
||||
|
||||
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'
|
||||
import './style.css'
|
||||
|
||||
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'),
|
||||
]
|
||||
|
||||
function App() {
|
||||
@@ -19,14 +21,23 @@ function App() {
|
||||
return (
|
||||
<main>
|
||||
<h1>Solid + Webpack</h1>
|
||||
<IconsIcon
|
||||
<AppIcon
|
||||
data-testid="icon"
|
||||
data-app="solid-webpack"
|
||||
icon="check"
|
||||
aria-label="Check icon"
|
||||
width={64}
|
||||
height={64}
|
||||
style={{ '--icon-color-1': '#16a34a' }}
|
||||
style={{ color: '#16a34a', '--icon-color-1': '#16a34a' }}
|
||||
/>
|
||||
<RemoteAppIcon
|
||||
data-testid="remote-icon"
|
||||
data-app="solid-webpack-remote"
|
||||
icon="check"
|
||||
aria-label="Remote check icon"
|
||||
width={64}
|
||||
height={64}
|
||||
style={{ color: '#16a34a', '--icon-color-1': '#16a34a' }}
|
||||
/>
|
||||
<gromlab-sprite-viewer ref={viewer} viewer-title="Solid Webpack Viewer" />
|
||||
</main>
|
||||
|
||||
2
integration/apps/solid-webpack/src/remote-app-icons/.gitignore
vendored
Normal file
2
integration/apps/solid-webpack/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/solid-webpack/src/remote-app-icons/index.d.ts
vendored
Normal file
1
integration/apps/solid-webpack/src/remote-app-icons/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './.svg-sprite/index.js'
|
||||
@@ -0,0 +1 @@
|
||||
export * from './.svg-sprite/index.js'
|
||||
@@ -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: 'solid@webpack',
|
||||
source: 'remote',
|
||||
input: manifestUrl,
|
||||
}
|
||||
Reference in New Issue
Block a user