litestar-vite 0.1.20__tar.gz → 0.1.22__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of litestar-vite might be problematic. Click here for more details.

Files changed (67) hide show
  1. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/PKG-INFO +2 -2
  2. {litestar_vite-0.1.20/examples/vanilla → litestar_vite-0.1.22/examples/basic}/app.py +0 -3
  3. litestar_vite-0.1.22/examples/basic/package-lock.json +398 -0
  4. litestar_vite-0.1.22/examples/basic/public/manifest.json +14 -0
  5. litestar_vite-0.1.22/examples/basic/resources/main.ts +1 -0
  6. {litestar_vite-0.1.20/examples/vanilla → litestar_vite-0.1.22/examples/basic}/tsconfig.json +5 -3
  7. {litestar_vite-0.1.20/examples/vanilla → litestar_vite-0.1.22/examples/basic}/vite.config.ts +15 -3
  8. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/cli.py +2 -0
  9. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/commands.py +18 -18
  10. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/config.py +13 -11
  11. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/loader.py +12 -13
  12. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/plugin.py +17 -9
  13. litestar_vite-0.1.22/litestar_vite/templates/main.ts.j2 +1 -0
  14. litestar_vite-0.1.22/package.json +11 -0
  15. litestar_vite-0.1.22/pdm.lock +1854 -0
  16. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/pyproject.toml +3 -2
  17. litestar_vite-0.1.22/tests/conftest.py +22 -0
  18. litestar_vite-0.1.22/tests/templates/index.html.j2 +18 -0
  19. litestar_vite-0.1.22/tests/test_cli/__init__.py +20 -0
  20. litestar_vite-0.1.22/tests/test_cli/conftest.py +154 -0
  21. litestar_vite-0.1.22/tests/test_cli/test_init.py +114 -0
  22. litestar_vite-0.1.22/tests/test_commands.py +13 -0
  23. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/tests/test_config.py +4 -0
  24. litestar_vite-0.1.20/examples/vanilla/package-lock.json +0 -920
  25. litestar_vite-0.1.20/examples/vanilla/package.json +0 -18
  26. litestar_vite-0.1.20/pdm.lock +0 -2026
  27. litestar_vite-0.1.20/tests/conftest.py +0 -16
  28. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/CODEOWNERS +0 -0
  29. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/workflows/cd.yaml +0 -0
  30. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/workflows/ci.yaml +0 -0
  31. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/workflows/docs-preview.yaml +0 -0
  32. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/workflows/docs.yaml +0 -0
  33. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/workflows/pr-title.yaml +0 -0
  34. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.github/workflows/publish.yaml +0 -0
  35. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.gitignore +0 -0
  36. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/.pre-commit-config.yaml +0 -0
  37. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/CONTRIBUTING.rst +0 -0
  38. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/LICENSE +0 -0
  39. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/Makefile +0 -0
  40. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/README.md +0 -0
  41. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/Makefile +0 -0
  42. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/conf.py +0 -0
  43. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/contribution-guide.rst +0 -0
  44. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/fix_missing_references.py +0 -0
  45. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/index.rst +0 -0
  46. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/reference/config.rst +0 -0
  47. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/reference/plugin.rst +0 -0
  48. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/usage/index.rst +0 -0
  49. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/docs/usage/placeholder.rst +0 -0
  50. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/examples/__init__.py +0 -0
  51. {litestar_vite-0.1.20 → litestar_vite-0.1.22/examples/basic}/package.json +0 -0
  52. /litestar_vite-0.1.20/examples/vanilla/__init__.py → /litestar_vite-0.1.22/examples/basic/public/assets/main-l0sNRNKZ.js +0 -0
  53. /litestar_vite-0.1.20/examples/vanilla/resources/main.ts → /litestar_vite-0.1.22/examples/basic/public/assets/styles-l0sNRNKZ.js +0 -0
  54. {litestar_vite-0.1.20/examples/vanilla → litestar_vite-0.1.22/examples/basic}/resources/styles.css +0 -0
  55. {litestar_vite-0.1.20/examples/vanilla → litestar_vite-0.1.22/examples/basic}/templates/index.html.j2 +0 -0
  56. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/__init__.py +0 -0
  57. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/__metadata__.py +0 -0
  58. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/py.typed +0 -0
  59. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/template_engine.py +0 -0
  60. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/templates/__init__.py +0 -0
  61. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/templates/index.html.j2 +0 -0
  62. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/templates/package.json.j2 +0 -0
  63. /litestar_vite-0.1.20/litestar_vite/templates/main.css.j2 → /litestar_vite-0.1.22/litestar_vite/templates/styles.css.j2 +0 -0
  64. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/templates/tsconfig.json.j2 +0 -0
  65. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/litestar_vite/templates/vite.config.ts.j2 +0 -0
  66. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/package-lock.json +0 -0
  67. {litestar_vite-0.1.20 → litestar_vite-0.1.22}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: litestar-vite
3
- Version: 0.1.20
3
+ Version: 0.1.22
4
4
  Summary: Vite plugin for Litestar
5
5
  Project-URL: Changelog, https://cofin.github.io/litestar-vite/latest/changelog
6
6
  Project-URL: Discord, https://discord.gg/X3FJqy8d2j
@@ -30,7 +30,7 @@ Classifier: Topic :: Database :: Database Engines/Servers
30
30
  Classifier: Topic :: Software Development
31
31
  Classifier: Typing :: Typed
32
32
  Requires-Python: >=3.8
33
- Requires-Dist: litestar[cli,jinja]>=2.4.0
33
+ Requires-Dist: litestar[jinja]>=2.4.0
34
34
  Provides-Extra: nodeenv
35
35
  Requires-Dist: nodeenv; extra == 'nodeenv'
36
36
  Description-Content-Type: text/markdown
@@ -24,9 +24,6 @@ class WebController(Controller):
24
24
 
25
25
  vite = VitePlugin(
26
26
  config=ViteConfig(
27
- bundle_dir=Path(here / "public"),
28
- resource_dir=Path(here / "resources"),
29
- template_dir=Path(here / "templates"),
30
27
  hot_reload=True,
31
28
  port=3006,
32
29
  use_server_lifespan=True,
@@ -0,0 +1,398 @@
1
+ {
2
+ "name": "tailwind",
3
+ "lockfileVersion": 3,
4
+ "requires": true,
5
+ "packages": {
6
+ "": {
7
+ "dependencies": {
8
+ "axios": "^1.6.2"
9
+ },
10
+ "devDependencies": {
11
+ "@types/node": "^20.10.3",
12
+ "litestar-vite-plugin": "^0.5.1",
13
+ "typescript": "^5.3.3",
14
+ "vite": "^5.0.6"
15
+ }
16
+ },
17
+ "node_modules/@esbuild/linux-x64": {
18
+ "version": "0.20.2",
19
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz",
20
+ "integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==",
21
+ "cpu": [
22
+ "x64"
23
+ ],
24
+ "dev": true,
25
+ "optional": true,
26
+ "os": [
27
+ "linux"
28
+ ],
29
+ "engines": {
30
+ "node": ">=12"
31
+ }
32
+ },
33
+ "node_modules/@rollup/rollup-linux-x64-gnu": {
34
+ "version": "4.13.0",
35
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.13.0.tgz",
36
+ "integrity": "sha512-yUD/8wMffnTKuiIsl6xU+4IA8UNhQ/f1sAnQebmE/lyQ8abjsVyDkyRkWop0kdMhKMprpNIhPmYlCxgHrPoXoA==",
37
+ "cpu": [
38
+ "x64"
39
+ ],
40
+ "dev": true,
41
+ "optional": true,
42
+ "os": [
43
+ "linux"
44
+ ]
45
+ },
46
+ "node_modules/@types/estree": {
47
+ "version": "1.0.5",
48
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
49
+ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
50
+ "dev": true
51
+ },
52
+ "node_modules/@types/node": {
53
+ "version": "20.11.30",
54
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz",
55
+ "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==",
56
+ "dev": true,
57
+ "dependencies": {
58
+ "undici-types": "~5.26.4"
59
+ }
60
+ },
61
+ "node_modules/asynckit": {
62
+ "version": "0.4.0",
63
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
64
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
65
+ },
66
+ "node_modules/axios": {
67
+ "version": "1.6.8",
68
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
69
+ "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
70
+ "dependencies": {
71
+ "follow-redirects": "^1.15.6",
72
+ "form-data": "^4.0.0",
73
+ "proxy-from-env": "^1.1.0"
74
+ }
75
+ },
76
+ "node_modules/combined-stream": {
77
+ "version": "1.0.8",
78
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
79
+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
80
+ "dependencies": {
81
+ "delayed-stream": "~1.0.0"
82
+ },
83
+ "engines": {
84
+ "node": ">= 0.8"
85
+ }
86
+ },
87
+ "node_modules/delayed-stream": {
88
+ "version": "1.0.0",
89
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
90
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
91
+ "engines": {
92
+ "node": ">=0.4.0"
93
+ }
94
+ },
95
+ "node_modules/esbuild": {
96
+ "version": "0.20.2",
97
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz",
98
+ "integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==",
99
+ "dev": true,
100
+ "hasInstallScript": true,
101
+ "bin": {
102
+ "esbuild": "bin/esbuild"
103
+ },
104
+ "engines": {
105
+ "node": ">=12"
106
+ },
107
+ "optionalDependencies": {
108
+ "@esbuild/aix-ppc64": "0.20.2",
109
+ "@esbuild/android-arm": "0.20.2",
110
+ "@esbuild/android-arm64": "0.20.2",
111
+ "@esbuild/android-x64": "0.20.2",
112
+ "@esbuild/darwin-arm64": "0.20.2",
113
+ "@esbuild/darwin-x64": "0.20.2",
114
+ "@esbuild/freebsd-arm64": "0.20.2",
115
+ "@esbuild/freebsd-x64": "0.20.2",
116
+ "@esbuild/linux-arm": "0.20.2",
117
+ "@esbuild/linux-arm64": "0.20.2",
118
+ "@esbuild/linux-ia32": "0.20.2",
119
+ "@esbuild/linux-loong64": "0.20.2",
120
+ "@esbuild/linux-mips64el": "0.20.2",
121
+ "@esbuild/linux-ppc64": "0.20.2",
122
+ "@esbuild/linux-riscv64": "0.20.2",
123
+ "@esbuild/linux-s390x": "0.20.2",
124
+ "@esbuild/linux-x64": "0.20.2",
125
+ "@esbuild/netbsd-x64": "0.20.2",
126
+ "@esbuild/openbsd-x64": "0.20.2",
127
+ "@esbuild/sunos-x64": "0.20.2",
128
+ "@esbuild/win32-arm64": "0.20.2",
129
+ "@esbuild/win32-ia32": "0.20.2",
130
+ "@esbuild/win32-x64": "0.20.2"
131
+ }
132
+ },
133
+ "node_modules/follow-redirects": {
134
+ "version": "1.15.6",
135
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
136
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
137
+ "funding": [
138
+ {
139
+ "type": "individual",
140
+ "url": "https://github.com/sponsors/RubenVerborgh"
141
+ }
142
+ ],
143
+ "engines": {
144
+ "node": ">=4.0"
145
+ },
146
+ "peerDependenciesMeta": {
147
+ "debug": {
148
+ "optional": true
149
+ }
150
+ }
151
+ },
152
+ "node_modules/form-data": {
153
+ "version": "4.0.0",
154
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
155
+ "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
156
+ "dependencies": {
157
+ "asynckit": "^0.4.0",
158
+ "combined-stream": "^1.0.8",
159
+ "mime-types": "^2.1.12"
160
+ },
161
+ "engines": {
162
+ "node": ">= 6"
163
+ }
164
+ },
165
+ "node_modules/litestar-vite-plugin": {
166
+ "version": "0.5.1",
167
+ "resolved": "https://registry.npmjs.org/litestar-vite-plugin/-/litestar-vite-plugin-0.5.1.tgz",
168
+ "integrity": "sha512-Zw0CFj9M4eP6A6pw7FIS9qne4C3+eSBAnnOLlI8fbgYLdSCdPbHmCUjVbM0W81G8ZJQ2aQB3S0KFQLt3hNVdzw==",
169
+ "dev": true,
170
+ "dependencies": {
171
+ "picocolors": "^1.0.0",
172
+ "vite-plugin-full-reload": "^1.1.0"
173
+ },
174
+ "bin": {
175
+ "clean-orphaned-assets": "bin/clean.js"
176
+ },
177
+ "engines": {
178
+ "node": "^18.0.0 || >=20.0.0"
179
+ },
180
+ "peerDependencies": {
181
+ "vite": "^5.0.0"
182
+ }
183
+ },
184
+ "node_modules/mime-db": {
185
+ "version": "1.52.0",
186
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
187
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
188
+ "engines": {
189
+ "node": ">= 0.6"
190
+ }
191
+ },
192
+ "node_modules/mime-types": {
193
+ "version": "2.1.35",
194
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
195
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
196
+ "dependencies": {
197
+ "mime-db": "1.52.0"
198
+ },
199
+ "engines": {
200
+ "node": ">= 0.6"
201
+ }
202
+ },
203
+ "node_modules/nanoid": {
204
+ "version": "3.3.7",
205
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
206
+ "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
207
+ "dev": true,
208
+ "funding": [
209
+ {
210
+ "type": "github",
211
+ "url": "https://github.com/sponsors/ai"
212
+ }
213
+ ],
214
+ "bin": {
215
+ "nanoid": "bin/nanoid.cjs"
216
+ },
217
+ "engines": {
218
+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
219
+ }
220
+ },
221
+ "node_modules/picocolors": {
222
+ "version": "1.0.0",
223
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
224
+ "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
225
+ "dev": true
226
+ },
227
+ "node_modules/picomatch": {
228
+ "version": "2.3.1",
229
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
230
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
231
+ "dev": true,
232
+ "engines": {
233
+ "node": ">=8.6"
234
+ },
235
+ "funding": {
236
+ "url": "https://github.com/sponsors/jonschlinkert"
237
+ }
238
+ },
239
+ "node_modules/postcss": {
240
+ "version": "8.4.38",
241
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
242
+ "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==",
243
+ "dev": true,
244
+ "funding": [
245
+ {
246
+ "type": "opencollective",
247
+ "url": "https://opencollective.com/postcss/"
248
+ },
249
+ {
250
+ "type": "tidelift",
251
+ "url": "https://tidelift.com/funding/github/npm/postcss"
252
+ },
253
+ {
254
+ "type": "github",
255
+ "url": "https://github.com/sponsors/ai"
256
+ }
257
+ ],
258
+ "dependencies": {
259
+ "nanoid": "^3.3.7",
260
+ "picocolors": "^1.0.0",
261
+ "source-map-js": "^1.2.0"
262
+ },
263
+ "engines": {
264
+ "node": "^10 || ^12 || >=14"
265
+ }
266
+ },
267
+ "node_modules/proxy-from-env": {
268
+ "version": "1.1.0",
269
+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
270
+ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
271
+ },
272
+ "node_modules/rollup": {
273
+ "version": "4.13.0",
274
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.13.0.tgz",
275
+ "integrity": "sha512-3YegKemjoQnYKmsBlOHfMLVPPA5xLkQ8MHLLSw/fBrFaVkEayL51DilPpNNLq1exr98F2B1TzrV0FUlN3gWRPg==",
276
+ "dev": true,
277
+ "dependencies": {
278
+ "@types/estree": "1.0.5"
279
+ },
280
+ "bin": {
281
+ "rollup": "dist/bin/rollup"
282
+ },
283
+ "engines": {
284
+ "node": ">=18.0.0",
285
+ "npm": ">=8.0.0"
286
+ },
287
+ "optionalDependencies": {
288
+ "@rollup/rollup-android-arm-eabi": "4.13.0",
289
+ "@rollup/rollup-android-arm64": "4.13.0",
290
+ "@rollup/rollup-darwin-arm64": "4.13.0",
291
+ "@rollup/rollup-darwin-x64": "4.13.0",
292
+ "@rollup/rollup-linux-arm-gnueabihf": "4.13.0",
293
+ "@rollup/rollup-linux-arm64-gnu": "4.13.0",
294
+ "@rollup/rollup-linux-arm64-musl": "4.13.0",
295
+ "@rollup/rollup-linux-riscv64-gnu": "4.13.0",
296
+ "@rollup/rollup-linux-x64-gnu": "4.13.0",
297
+ "@rollup/rollup-linux-x64-musl": "4.13.0",
298
+ "@rollup/rollup-win32-arm64-msvc": "4.13.0",
299
+ "@rollup/rollup-win32-ia32-msvc": "4.13.0",
300
+ "@rollup/rollup-win32-x64-msvc": "4.13.0",
301
+ "fsevents": "~2.3.2"
302
+ }
303
+ },
304
+ "node_modules/source-map-js": {
305
+ "version": "1.2.0",
306
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
307
+ "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
308
+ "dev": true,
309
+ "engines": {
310
+ "node": ">=0.10.0"
311
+ }
312
+ },
313
+ "node_modules/typescript": {
314
+ "version": "5.4.3",
315
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz",
316
+ "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==",
317
+ "dev": true,
318
+ "bin": {
319
+ "tsc": "bin/tsc",
320
+ "tsserver": "bin/tsserver"
321
+ },
322
+ "engines": {
323
+ "node": ">=14.17"
324
+ }
325
+ },
326
+ "node_modules/undici-types": {
327
+ "version": "5.26.5",
328
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
329
+ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
330
+ "dev": true
331
+ },
332
+ "node_modules/vite": {
333
+ "version": "5.2.3",
334
+ "resolved": "https://registry.npmjs.org/vite/-/vite-5.2.3.tgz",
335
+ "integrity": "sha512-+i1oagbvkVIhEy9TnEV+fgXsng13nZM90JQbrcPrf6DvW2mXARlz+DK7DLiDP+qeKoD1FCVx/1SpFL1CLq9Mhw==",
336
+ "dev": true,
337
+ "dependencies": {
338
+ "esbuild": "^0.20.1",
339
+ "postcss": "^8.4.36",
340
+ "rollup": "^4.13.0"
341
+ },
342
+ "bin": {
343
+ "vite": "bin/vite.js"
344
+ },
345
+ "engines": {
346
+ "node": "^18.0.0 || >=20.0.0"
347
+ },
348
+ "funding": {
349
+ "url": "https://github.com/vitejs/vite?sponsor=1"
350
+ },
351
+ "optionalDependencies": {
352
+ "fsevents": "~2.3.3"
353
+ },
354
+ "peerDependencies": {
355
+ "@types/node": "^18.0.0 || >=20.0.0",
356
+ "less": "*",
357
+ "lightningcss": "^1.21.0",
358
+ "sass": "*",
359
+ "stylus": "*",
360
+ "sugarss": "*",
361
+ "terser": "^5.4.0"
362
+ },
363
+ "peerDependenciesMeta": {
364
+ "@types/node": {
365
+ "optional": true
366
+ },
367
+ "less": {
368
+ "optional": true
369
+ },
370
+ "lightningcss": {
371
+ "optional": true
372
+ },
373
+ "sass": {
374
+ "optional": true
375
+ },
376
+ "stylus": {
377
+ "optional": true
378
+ },
379
+ "sugarss": {
380
+ "optional": true
381
+ },
382
+ "terser": {
383
+ "optional": true
384
+ }
385
+ }
386
+ },
387
+ "node_modules/vite-plugin-full-reload": {
388
+ "version": "1.1.0",
389
+ "resolved": "https://registry.npmjs.org/vite-plugin-full-reload/-/vite-plugin-full-reload-1.1.0.tgz",
390
+ "integrity": "sha512-3cObNDzX6DdfhD9E7kf6w2mNunFpD7drxyNgHLw+XwIYAgb+Xt16SEXo0Up4VH+TMf3n+DSVJZtW2POBGcBYAA==",
391
+ "dev": true,
392
+ "dependencies": {
393
+ "picocolors": "^1.0.0",
394
+ "picomatch": "^2.3.1"
395
+ }
396
+ }
397
+ }
398
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "resources/main.ts": {
3
+ "file": "assets/main-l0sNRNKZ.js",
4
+ "name": "main",
5
+ "src": "resources/main.ts",
6
+ "isEntry": true
7
+ },
8
+ "resources/styles.css": {
9
+ "file": "assets/styles-l0sNRNKZ.js",
10
+ "name": "styles",
11
+ "src": "resources/styles.css",
12
+ "isEntry": true
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ import "@/styles.css"
@@ -17,12 +17,14 @@
17
17
  "baseUrl": "resources",
18
18
  "paths": {
19
19
  "@/*": ["./*"]
20
- }
20
+ },
21
+ "types": ["vite/client"]
21
22
  },
22
23
  "include": [
24
+
23
25
  "**/*.d.ts",
24
- "resources/**/*.js",
25
- "resources/**/*.ts",
26
+ "resources/**/*.js" ,
27
+ "resources/**/*.ts" ,
26
28
  "vite.config.ts"
27
29
  ]
28
30
  }
@@ -1,5 +1,6 @@
1
1
  import { defineConfig } from "vite";
2
2
 
3
+
3
4
  import litestar from "litestar-vite-plugin";
4
5
 
5
6
  const ASSET_URL = process.env.ASSET_URL || "/static/";
@@ -7,20 +8,31 @@ const VITE_PORT = process.env.VITE_PORT || "5173";
7
8
  const VITE_HOST = process.env.VITE_HOST || "localhost";
8
9
  export default defineConfig({
9
10
  base: `${ASSET_URL}`,
11
+ root: ".",
10
12
  server: {
11
- host: `${VITE_HOST}`,
13
+ host: "0.0.0.0",
12
14
  port: +`${VITE_PORT}`,
13
15
  cors: true,
16
+ hmr: {
17
+ host: `${VITE_HOST}`,
18
+ },
14
19
  },
15
20
  plugins: [
21
+
22
+
16
23
  litestar({
17
- input: ["resources/styles.css", "resources/main.ts"],
24
+ input: [
25
+ "resources/main.ts", "resources/styles.css"
26
+ ],
18
27
  assetUrl: `${ASSET_URL}`,
28
+ bundleDirectory: "public",
29
+ resourceDirectory: "resources",
30
+ hotFile: "public/hot"
19
31
  }),
20
32
  ],
21
33
  resolve: {
22
34
  alias: {
23
- "@": "resources",
35
+ "@": "resources"
24
36
  },
25
37
  },
26
38
  });
@@ -144,6 +144,8 @@ def vite_init(
144
144
  console.print("Skipping Vite initialization")
145
145
  sys.exit(2)
146
146
  for output_path in (bundle_path, resource_path, root_path):
147
+ if output_path.exists():
148
+ console.print(f" * Creating {output_path!s}")
147
149
  output_path.mkdir(parents=True, exist_ok=True)
148
150
 
149
151
  enable_ssr = (
@@ -5,16 +5,12 @@ import subprocess
5
5
  from pathlib import Path
6
6
  from typing import TYPE_CHECKING, Any, MutableMapping
7
7
 
8
- from jinja2 import select_autoescape
9
- from litestar.serialization import encode_json
10
-
11
8
  if TYPE_CHECKING:
12
9
  from jinja2 import Environment, Template
13
10
  from litestar import Litestar
14
11
 
15
- VITE_INIT_TEMPLATES_PATH = f"{Path(__file__).parent}/templates"
16
12
  VITE_INIT_TEMPLATES: set[str] = {"package.json.j2", "tsconfig.json.j2", "vite.config.ts.j2"}
17
- DEFAULT_RESOURCES: set[str] = {"styles.css", "main.ts"}
13
+ DEFAULT_RESOURCES: set[str] = {"styles.css.j2", "main.ts.j2"}
18
14
  DEFAULT_DEV_DEPENDENCIES: dict[str, str] = {
19
15
  "typescript": "^5.3.3",
20
16
  "vite": "^5.0.6",
@@ -33,6 +29,8 @@ def to_json(value: Any) -> str:
33
29
  Returns:
34
30
  JSON string.
35
31
  """
32
+ from litestar.serialization import encode_json
33
+
36
34
  return encode_json(value).decode("utf-8")
37
35
 
38
36
 
@@ -49,12 +47,13 @@ def init_vite(
49
47
  litestar_port: int,
50
48
  ) -> None:
51
49
  """Initialize a new vite project."""
52
- from jinja2 import Environment, FileSystemLoader
50
+ from jinja2 import Environment, FileSystemLoader, select_autoescape
53
51
  from litestar.cli._utils import console
52
+ from litestar.utils import module_loader
54
53
 
55
- entry_point: list[str] = []
54
+ template_path = module_loader.module_to_os_path("litestar_vite.templates")
56
55
  vite_template_env = Environment(
57
- loader=FileSystemLoader([VITE_INIT_TEMPLATES_PATH]),
56
+ loader=FileSystemLoader([template_path]),
58
57
  autoescape=select_autoescape(),
59
58
  )
60
59
 
@@ -66,25 +65,23 @@ def init_vite(
66
65
  template_name: get_template(environment=vite_template_env, name=template_name)
67
66
  for template_name in enabled_templates
68
67
  }
69
- entry_point = [
70
- str(Path(resource_path / resource_name).relative_to(Path.cwd().absolute()))
71
- for resource_name in enabled_resources
72
- ]
73
68
  for template_name, template in templates.items():
74
69
  target_file_name = template_name.removesuffix(".j2")
75
70
  with Path(target_file_name).open(mode="w") as file:
76
- console.print(f" * Writing {target_file_name} to {Path(target_file_name).absolute()}")
71
+ console.print(f" * Writing {target_file_name} to {Path(target_file_name)!s}")
77
72
 
78
73
  file.write(
79
74
  template.render(
80
- entry_point=entry_point,
75
+ entry_point=[
76
+ f"{resource_path!s}/{resource_name.removesuffix('.j2')}" for resource_name in enabled_resources
77
+ ],
81
78
  enable_ssr=enable_ssr,
82
79
  asset_url=asset_url,
83
- root_path=str(root_path.relative_to(Path.cwd().absolute())),
80
+ root_path=root_path,
84
81
  resource_path=str(resource_path.relative_to(root_path)),
85
82
  public_path=str(public_path.relative_to(root_path)),
86
83
  bundle_path=str(bundle_path.relative_to(root_path)),
87
- hot_file=str(hot_file.relative_to(Path.cwd().absolute())),
84
+ hot_file=str(hot_file.relative_to(root_path)),
88
85
  vite_port=str(vite_port),
89
86
  litestar_port=litestar_port,
90
87
  dependencies=to_json(dependencies),
@@ -93,8 +90,11 @@ def init_vite(
93
90
  )
94
91
 
95
92
  for resource_name in enabled_resources:
96
- with Path(resource_path / resource_name).open(mode="w") as file:
97
- console.print(f" * Writing {resource_name} to {Path(resource_path / resource_name).absolute()}")
93
+ template = get_template(environment=vite_template_env, name=resource_name)
94
+ target_file_name = f"{resource_path}/{resource_name.removesuffix('.j2')}"
95
+ with Path(target_file_name).open(mode="w") as file:
96
+ console.print(f" * Writing {resource_name.removesuffix('.j2')} to {Path(target_file_name)!s}")
97
+ file.write(template.render())
98
98
  console.print("[yellow]Vite initialization completed.[/]")
99
99
 
100
100
 
@@ -18,9 +18,8 @@ if TYPE_CHECKING:
18
18
 
19
19
  from litestar.types import PathType
20
20
 
21
- from litestar_vite.template_engine import ViteTemplateEngine
22
21
 
23
- T = TypeVar("T", bound=TemplateEngineProtocol)
22
+ EngineType = TypeVar("EngineType", bound=TemplateEngineProtocol)
24
23
 
25
24
 
26
25
  @dataclass
@@ -127,7 +126,7 @@ class ViteConfig:
127
126
 
128
127
 
129
128
  @dataclass
130
- class ViteTemplateConfig(Generic[T]):
129
+ class ViteTemplateConfig(Generic[EngineType]):
131
130
  """Configuration for Templating.
132
131
 
133
132
  To enable templating, pass an instance of this class to the
@@ -135,27 +134,30 @@ class ViteTemplateConfig(Generic[T]):
135
134
  'template_config' key.
136
135
  """
137
136
 
138
- engine: type[ViteTemplateEngine]
139
- """A template engine adhering to the :class:`TemplateEngineProtocol
140
- <litestar.template.base.TemplateEngineProtocol>`."""
141
137
  config: ViteConfig
142
138
  """A a config for the vite engine`."""
143
- directory: PathType | None = field(default=None)
139
+ engine: type[EngineType] | EngineType | None = field(default=None)
140
+ """A template engine adhering to the :class:`TemplateEngineProtocol
141
+ <litestar.template.base.TemplateEngineProtocol>`."""
142
+ directory: PathType | list[PathType] | None = field(default=None)
144
143
  """A directory or list of directories from which to serve templates."""
145
- engine_callback: Callable[[T], None] | None = field(default=None)
144
+ engine_callback: Callable[[EngineType], None] | None = field(default=None)
146
145
  """A callback function that allows modifying the instantiated templating
147
146
  protocol."""
148
147
 
148
+ instance: EngineType | None = field(default=None)
149
+ """An instance of the templating protocol."""
150
+
149
151
  def __post_init__(self) -> None:
150
152
  """Ensure that directory is set if engine is a class."""
151
153
  if isclass(self.engine) and not self.directory:
152
154
  msg = "directory is a required kwarg when passing a template engine class"
153
155
  raise ImproperlyConfiguredException(msg)
154
156
 
155
- def to_engine(self) -> T:
157
+ def to_engine(self) -> EngineType:
156
158
  """Instantiate the template engine."""
157
159
  template_engine = cast(
158
- "T",
160
+ "EngineType",
159
161
  self.engine(directory=self.directory, config=self.config) if isclass(self.engine) else self.engine,
160
162
  )
161
163
  if callable(self.engine_callback):
@@ -163,6 +165,6 @@ class ViteTemplateConfig(Generic[T]):
163
165
  return template_engine
164
166
 
165
167
  @cached_property
166
- def engine_instance(self) -> T:
168
+ def engine_instance(self) -> EngineType:
167
169
  """Return the template engine instance."""
168
170
  return self.to_engine()