Skip to content

Commit 25cab41

Browse files
authored
feat: Add vite-plugin-icons-spritesheet instead of the custom build script (#984)
* feat: Add vite-plugin-icons-spritesheet instead of the custom build script * fix for workflow * chore: fix workflow
1 parent e59a9c9 commit 25cab41

File tree

6 files changed

+39
-175
lines changed

6 files changed

+39
-175
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ jobs:
3131
uses: bahmutov/npm-install@v1
3232

3333
- name: 🏄 Copy test env vars
34-
run: cp .env.example .env
35-
36-
- name: 🖼 Build icons
37-
run: npm run build:icons
34+
run: cp .env.example .env
3835

3936
- name: 🛠 Setup Database
4037
run: npx prisma migrate deploy && npx prisma generate --sql
@@ -57,11 +54,11 @@ jobs:
5754
- name: 📥 Download deps
5855
uses: bahmutov/npm-install@v1
5956

60-
- name: 🏄 Copy test env vars
61-
run: cp .env.example .env
57+
- name: 🏗 Build
58+
run: npm run build
6259

63-
- name: 🖼 Build icons
64-
run: npm run build:icons
60+
- name: 🏄 Copy test env vars
61+
run: cp .env.example .env
6562

6663
- name: 🛠 Setup Database
6764
run: npx prisma migrate deploy && npx prisma generate --sql
@@ -85,10 +82,7 @@ jobs:
8582
uses: bahmutov/npm-install@v1
8683

8784
- name: 🏄 Copy test env vars
88-
run: cp .env.example .env
89-
90-
- name: 🖼 Build icons
91-
run: npm run build:icons
85+
run: cp .env.example .env
9286

9387
- name: 🛠 Setup Database
9488
run: npx prisma migrate deploy && npx prisma generate --sql

other/build-icons.ts

Lines changed: 0 additions & 153 deletions
This file was deleted.

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
},
1212
"scripts": {
1313
"build": "run-s build:*",
14-
"build:icons": "tsx ./other/build-icons.ts",
1514
"build:remix": "react-router build",
1615
"build:server": "tsx ./other/build-server.ts",
17-
"predev": "npm run build:icons --silent",
1816
"dev": "cross-env NODE_ENV=development MOCKS=true node ./server/dev-server.js",
1917
"dev:no-mocks": "cross-env NODE_ENV=development node ./server/dev-server.js",
2018
"format": "prettier --write .",
@@ -147,7 +145,6 @@
147145
"fs-extra": "^11.3.0",
148146
"jsdom": "^25.0.1",
149147
"msw": "^2.7.3",
150-
"node-html-parser": "^7.0.1",
151148
"npm-run-all": "^4.1.5",
152149
"prettier": "^3.5.3",
153150
"prettier-plugin-sql": "^0.18.1",
@@ -157,6 +154,7 @@
157154
"tw-animate-css": "^1.2.4",
158155
"typescript": "^5.8.2",
159156
"vite": "^6.2.2",
157+
"vite-plugin-icons-spritesheet": "^3.0.1",
160158
"vitest": "^3.0.9"
161159
},
162160
"engines": {
@@ -166,4 +164,4 @@
166164
"seed": "tsx prisma/seed.ts"
167165
},
168166
"prettier": "@epic-web/config/prettier"
169-
}
167+
}

tsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
"paths": {
99
"#app/*": ["./app/*"],
1010
"#tests/*": ["./tests/*"],
11-
"@/icon-name": [
12-
"./app/components/ui/icons/name.d.ts",
13-
"./types/icon-name.d.ts"
14-
]
11+
"@/icon-name": ["./app/components/ui/icons/types.ts", "./types/types.ts"]
1512
}
1613
}
1714
}

vite.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { reactRouter } from '@react-router/dev/vite'
22
import {
3-
sentryReactRouter,
43
type SentryReactRouterBuildOptions,
4+
sentryReactRouter,
55
} from '@sentry/react-router'
66
import tailwindcss from '@tailwindcss/vite'
77
import { defineConfig } from 'vite'
88
import { envOnlyMacros } from 'vite-env-only'
9+
import { iconsSpritesheet } from 'vite-plugin-icons-spritesheet'
910

1011
const MODE = process.env.NODE_ENV
1112

@@ -20,7 +21,6 @@ export default defineConfig((config) => ({
2021

2122
assetsInlineLimit: (source: string) => {
2223
if (
23-
source.endsWith('sprite.svg') ||
2424
source.endsWith('favicon.svg') ||
2525
source.endsWith('apple-touch-icon.png')
2626
) {
@@ -39,6 +39,13 @@ export default defineConfig((config) => ({
3939
plugins: [
4040
envOnlyMacros(),
4141
tailwindcss(),
42+
iconsSpritesheet({
43+
inputDir: './other/svg-icons',
44+
outputDir: './app/components/ui/icons',
45+
fileName: 'sprite.svg',
46+
withTypes: true,
47+
iconNameTransformer: (name) => name,
48+
}),
4249
// it would be really nice to have this enabled in tests, but we'll have to
4350
// wait until https://github.com/remix-run/remix/issues/9871 is fixed
4451
MODE === 'test' ? null : reactRouter(),

0 commit comments

Comments
 (0)