Skip to content

Commit d0c0ced

Browse files
committed
refactor: update deps and remove single-file bundling
- update vite to 8.0.8, typescript to 6.0.2, and minor dependency patches - replace vite-plugin-singlefile with prettier plugins for formatting - remove custom SVG URL replacement plugin - adjust tsconfig paths to use relative "./src/*" alias - refactor UI components to use array syntax for element children BREAKING CHANGE: Removal of vite-plugin-singlefile changes output from inline single HTML file to standard bundled assets. Users relying on the single-file output will need to adjust their deployment workflow.
1 parent a640b45 commit d0c0ced

7 files changed

Lines changed: 839 additions & 878 deletions

File tree

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@
1111
},
1212
"devDependencies": {
1313
"@crashmax/prettier-config": "5.0.2",
14-
"@types/node": "22.7.5",
15-
"sass-embedded": "1.79.5",
16-
"typescript": "5.6.3",
17-
"vite": "5.4.9",
18-
"vite-plugin-singlefile": "2.0.2"
14+
"@ianvs/prettier-plugin-sort-imports": "4.7.1",
15+
"@types/node": "22.19.17",
16+
"prettier-plugin-multiline-arrays": "^4.1.5",
17+
"sass-embedded": "1.99.0",
18+
"typescript": "6.0.2",
19+
"vite": "8.0.8"
1920
},
2021
"dependencies": {
21-
"@zero-dependency/dom": "1.8.4",
22+
"@zero-dependency/dom": "1.8.5",
2223
"@zero-dependency/storage": "1.3.4",
23-
"@zero-dependency/utils": "1.7.7"
24+
"@zero-dependency/utils": "1.7.8"
2425
}
2526
}

pnpm-lock.yaml

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

src/credits.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { el } from '@zero-dependency/dom'
22

3-
export const credits = el(
4-
'div',
5-
{ className: 'credits' },
3+
export const credits = el('div', { className: 'credits' }, [
64
'Сделано с',
75
el('span', { className: 'heart' }, '❤️'),
86
'от',
@@ -23,4 +21,4 @@ export const credits = el(
2321
},
2422
'VS_Code'
2523
)
26-
)
24+
])

src/header.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ const resetButton = el(
3131
'Сбросить прогресс'
3232
)
3333

34-
export const header = el(
35-
'header',
36-
{ className: 'header' },
34+
export const header = el('header', { className: 'header' }, [
3735
el('h1', { className: 'title' }, 'SFX Game Quiz'),
38-
el(
39-
'div',
40-
{ className: 'controls' },
41-
el('label', { className: 'volume-label' }, 'Громкость', volumeRange),
36+
el('div', { className: 'controls' }, [
37+
el('label', { className: 'volume-label' }, ['Громкость', volumeRange]),
4238
resetButton
43-
)
44-
)
39+
])
40+
])

src/render.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,26 @@ export function render() {
1919

2020
for (const [index, game] of Object.entries(GAMES)) {
2121
const gameIndex = Number(index)
22-
const gameItem = el('div', { className: 'grid-item' })
22+
const gameItem = el('label', {
23+
htmlFor: `game-${gameIndex}`,
24+
className: 'grid-item'
25+
})
2326

2427
const buttonIcon = el('img', { src: PlayIcon })
2528
const buttonPlay = el(
2629
'button',
2730
{
2831
className: 'play-button',
29-
onclick: () => audioPlayer.play(buttonIcon, game)
32+
onclick: () => {
33+
gameItem.focus()
34+
audioPlayer.play(buttonIcon, game)
35+
}
3036
},
3137
buttonIcon
3238
)
3339

3440
const input = el('input', {
41+
id: `game-${gameIndex}`,
3542
className: 'input',
3643
placeholder: `Игра #${gameIndex + 1}`,
3744
oninput: (event) => {

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
"isolatedModules": true,
1313
"moduleDetection": "force",
1414
"noEmit": true,
15-
"baseUrl": ".",
1615
"paths": {
17-
"@/*": ["src/*"],
16+
"@/*": ["./src/*"],
1817
},
1918

2019
/* Linting */

vite.config.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import { fileURLToPath } from 'node:url'
22
import { defineConfig } from 'vite'
3-
import { viteSingleFile } from 'vite-plugin-singlefile'
4-
import type { Plugin } from 'vite'
53

64
export default defineConfig({
75
define: {
86
__BUILD_DATE__: JSON.stringify(new Date().toISOString())
97
},
10-
plugins: [
11-
viteSingleFile(),
12-
replaceSvgUrl()
13-
],
148
build: {
159
target: 'esnext',
1610
minify: true,
@@ -22,25 +16,3 @@ export default defineConfig({
2216
}
2317
}
2418
})
25-
26-
function replaceSvgUrl(): Plugin {
27-
const svgUrl = 'http://www.w3.org/2000/svg'
28-
const svgUrlRegexp = new RegExp(svgUrl, 'g')
29-
const svgUrlBase64 = btoa(svgUrl)
30-
const svgUrlVariable = `const __SVG_URL__ = atob('${svgUrlBase64}');`
31-
32-
return {
33-
name: 'vite:replace-svg-url',
34-
apply: 'build',
35-
generateBundle(_, bundle) {
36-
for (const bundleIndex in bundle) {
37-
const file = bundle[bundleIndex]
38-
if (file.type === 'chunk') {
39-
file.code =
40-
svgUrlVariable +
41-
file.code.replaceAll(svgUrlRegexp, `"+__SVG_URL__+"`)
42-
}
43-
}
44-
}
45-
}
46-
}

0 commit comments

Comments
 (0)