From b779e1ba6e43fcf52baed54b867ad8f6f52778f6 Mon Sep 17 00:00:00 2001 From: Bedram Tamang Date: Wed, 6 May 2026 15:12:33 -0700 Subject: [PATCH] feat: vite publish command improved --- example/vite-app/bootstrap/application.py | 6 +- example/vite-app/config/vite.py | 4 - example/vite-app/package-lock.json | 102 ++++++++++++++-- example/vite-app/package.json | 15 ++- example/vite-app/resources/css/app.css | 105 +--------------- example/vite-app/resources/js/app.js | 14 --- example/vite-app/resources/js/app.ts | 23 ++++ example/vite-app/templates/index.html | 64 +++++++--- example/vite-app/tsconfig.json | 115 ++++++++++++++++++ .../{vite.config.js => vite.config.ts} | 2 +- .../vite/providers/provider.py | 6 +- .../fastapi_startkit/vite/stubs/package.json | 4 +- .../vite/stubs/resources/css/app.css | 5 +- .../vite/stubs/resources/js/app.js | 3 - .../vite/stubs/resources/js/app.ts | 23 ++++ .../vite/stubs/templates/index.html | 59 +++++++++ .../fastapi_startkit/vite/stubs/tsconfig.json | 115 ++++++++++++++++++ .../stubs/{vite.config.js => vite.config.ts} | 2 +- .../src/fastapi_startkit/vite/vite.py | 2 +- 19 files changed, 498 insertions(+), 171 deletions(-) delete mode 100644 example/vite-app/resources/js/app.js create mode 100644 example/vite-app/resources/js/app.ts create mode 100644 example/vite-app/tsconfig.json rename example/vite-app/{vite.config.js => vite.config.ts} (86%) delete mode 100644 fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.js create mode 100644 fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.ts create mode 100644 fastapi_startkit/src/fastapi_startkit/vite/stubs/templates/index.html create mode 100644 fastapi_startkit/src/fastapi_startkit/vite/stubs/tsconfig.json rename fastapi_startkit/src/fastapi_startkit/vite/stubs/{vite.config.js => vite.config.ts} (86%) diff --git a/example/vite-app/bootstrap/application.py b/example/vite-app/bootstrap/application.py index ce038b68..9dc64939 100644 --- a/example/vite-app/bootstrap/application.py +++ b/example/vite-app/bootstrap/application.py @@ -1,17 +1,17 @@ from pathlib import Path -from config.vite import ViteConfig from fastapi_startkit.application import Application from fastapi_startkit.logging import LogProvider from fastapi_startkit.vite import ViteProvider +# from config.vite import ViteConfig from providers.fastapi_provider import FastAPIProvider app: Application = Application( - base_path=str(Path.cwd()), + base_path=Path(__file__).resolve().parent.parent, providers=[ LogProvider, FastAPIProvider, - (ViteProvider, ViteConfig), + ViteProvider, ], ) diff --git a/example/vite-app/config/vite.py b/example/vite-app/config/vite.py index 15de0153..71431700 100644 --- a/example/vite-app/config/vite.py +++ b/example/vite-app/config/vite.py @@ -10,7 +10,3 @@ class ViteConfig: asset_url: str = "" static_url: str = "/build" mount_static: bool = True - - - - diff --git a/example/vite-app/package-lock.json b/example/vite-app/package-lock.json index 8800fbd5..fc3f0a86 100644 --- a/example/vite-app/package-lock.json +++ b/example/vite-app/package-lock.json @@ -1,17 +1,14 @@ { - "name": "vite-example", - "version": "0.1.0", + "name": "vite-app", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "vite-example", - "version": "0.1.0", - "dependencies": { - "@tailwindcss/vite": "^4.2.4", - "fastapi-vite-plugin": "^0.0.3" - }, "devDependencies": { + "@tailwindcss/vite": "^4.0.0", + "fastapi-vite-plugin": "^0.0.3", + "tailwindcss": "^4.0.0", + "typescript": "^5.0.0", "vite": "^8.0.0" } }, @@ -19,6 +16,7 @@ "version": "1.9.2", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz", "integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -30,6 +28,7 @@ "version": "1.9.2", "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz", "integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -40,6 +39,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -50,6 +50,7 @@ "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", @@ -60,6 +61,7 @@ "version": "2.3.5", "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", @@ -70,6 +72,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.0.0" @@ -79,12 +82,14 @@ "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.31", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -95,6 +100,7 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz", "integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -113,6 +119,7 @@ "version": "0.126.0", "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.126.0.tgz", "integrity": "sha512-oGfVtjAgwQVVpfBrbtk4e1XDyWHRFta6BS3GWVzrF8xYBT2VGQAk39yJS/wFSMrZqoiCU4oghT3Ch0HaHGIHcQ==", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/Boshen" @@ -125,6 +132,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -141,6 +149,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -157,6 +166,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -173,6 +183,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -189,6 +200,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -205,6 +217,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -221,6 +234,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -237,6 +251,7 @@ "cpu": [ "ppc64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -253,6 +268,7 @@ "cpu": [ "s390x" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -269,6 +285,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -285,6 +302,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -301,6 +319,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -317,6 +336,7 @@ "cpu": [ "wasm32" ], + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -335,6 +355,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -351,6 +372,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -364,12 +386,14 @@ "version": "1.0.0-rc.16", "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.16.tgz", "integrity": "sha512-45+YtqxLYKDWQouLKCrpIZhke+nXxhsw+qAHVzHDVwttyBlHNBVs2K25rDXrZzhpTp9w1FlAlvweV1H++fdZoA==", + "dev": true, "license": "MIT" }, "node_modules/@tailwindcss/node": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.2.4.tgz", "integrity": "sha512-Ai7+yQPxz3ddrDQzFfBKdHEVBg0w3Zl83jnjuwxnZOsnH9pGn93QHQtpU0p/8rYWxvbFZHneni6p1BSLK4DkGA==", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/remapping": "^2.3.5", @@ -385,6 +409,7 @@ "version": "4.2.4", "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.2.4.tgz", "integrity": "sha512-9El/iI069DKDSXwTvB9J4BwdO5JhRrOweGaK25taBAvBXyXqJAX+Jqdvs8r8gKpsI/1m0LeJLyQYTf/WLrBT1Q==", + "dev": true, "license": "MIT", "engines": { "node": ">= 20" @@ -411,6 +436,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -427,6 +453,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -443,6 +470,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -459,6 +487,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -475,6 +504,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -491,6 +521,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -507,6 +538,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -523,6 +555,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -539,6 +572,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -563,6 +597,7 @@ "cpu": [ "wasm32" ], + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -584,6 +619,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -600,6 +636,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -613,6 +650,7 @@ "version": "4.2.4", "resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.2.4.tgz", "integrity": "sha512-pCvohwOCspk3ZFn6eJzrrX3g4n2JY73H6MmYC87XfGPyTty4YsCjYTMArRZm/zOI8dIt3+EcrLHAFPe5A4bgtw==", + "dev": true, "license": "MIT", "dependencies": { "@tailwindcss/node": "4.2.4", @@ -627,6 +665,7 @@ "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -637,6 +676,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=8" @@ -646,6 +686,7 @@ "version": "5.21.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.0.tgz", "integrity": "sha512-otxSQPw4lkOZWkHpB3zaEQs6gWYEsmX4xQF68ElXC/TWvGxGMSGOvoNbaLXm6/cS/fSfHtsEdw90y20PCd+sCA==", + "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", @@ -659,6 +700,7 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/fastapi-vite-plugin/-/fastapi-vite-plugin-0.0.3.tgz", "integrity": "sha512-BzUPUquR5/pHZ36Id7jtudQHyn09r2SuP2EnmjUHXLJWpcZyh0i2w7bWtriwA9wLjgw+ZLmlWgI/Rf8EyYtdOw==", + "dev": true, "license": "MIT", "dependencies": { "picocolors": "^1.0.0", @@ -676,6 +718,7 @@ "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, "license": "MIT", "engines": { "node": ">=12.0.0" @@ -693,6 +736,7 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -707,12 +751,14 @@ "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, "license": "ISC" }, "node_modules/jiti": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, "license": "MIT", "bin": { "jiti": "lib/jiti-cli.mjs" @@ -722,6 +768,7 @@ "version": "1.32.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", + "dev": true, "license": "MPL-2.0", "dependencies": { "detect-libc": "^2.0.3" @@ -754,6 +801,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -774,6 +822,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -794,6 +843,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -814,6 +864,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -834,6 +885,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -854,6 +906,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -874,6 +927,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -894,6 +948,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -914,6 +969,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -934,6 +990,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -954,6 +1011,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MPL-2.0", "optional": true, "os": [ @@ -971,6 +1029,7 @@ "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" @@ -980,6 +1039,7 @@ "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "dev": true, "funding": [ { "type": "github", @@ -998,12 +1058,14 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, "license": "ISC" }, "node_modules/picomatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -1016,6 +1078,7 @@ "version": "8.5.10", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.10.tgz", "integrity": "sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==", + "dev": true, "funding": [ { "type": "opencollective", @@ -1044,6 +1107,7 @@ "version": "1.0.0-rc.16", "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.16.tgz", "integrity": "sha512-rzi5WqKzEZw3SooTt7cgm4eqIoujPIyGcJNGFL7iPEuajQw7vxMHUkXylu4/vhCkJGXsgRmxqMKXUpT6FEgl0g==", + "dev": true, "license": "MIT", "dependencies": { "@oxc-project/types": "=0.126.0", @@ -1077,6 +1141,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -1086,12 +1151,14 @@ "version": "4.2.4", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.4.tgz", "integrity": "sha512-HhKppgO81FQof5m6TEnuBWCZGgfRAWbaeOaGT00KOy/Pf/j6oUihdvBpA7ltCeAvZpFhW3j0PTclkxsd4IXYDA==", + "dev": true, "license": "MIT" }, "node_modules/tapable": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -1105,6 +1172,7 @@ "version": "0.2.16", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz", "integrity": "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==", + "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.5.0", @@ -1121,13 +1189,29 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, "license": "0BSD", "optional": true }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/vite": { "version": "8.0.9", "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.9.tgz", "integrity": "sha512-t7g7GVRpMXjNpa67HaVWI/8BWtdVIQPCL2WoozXXA7LBGEFK4AkkKkHx2hAQf5x1GZSlcmEDPkVLSGahxnEEZw==", + "dev": true, "license": "MIT", "dependencies": { "lightningcss": "^1.32.0", @@ -1205,6 +1289,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/vite-plugin-full-reload/-/vite-plugin-full-reload-1.2.0.tgz", "integrity": "sha512-kz18NW79x0IHbxRSHm0jttP4zoO9P9gXh+n6UTwlNKnviTTEpOlum6oS9SmecrTtSr+muHEn5TUuC75UovQzcA==", + "dev": true, "license": "MIT", "dependencies": { "picocolors": "^1.0.0", @@ -1215,6 +1300,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, "license": "MIT", "engines": { "node": ">=8.6" diff --git a/example/vite-app/package.json b/example/vite-app/package.json index ba033d20..addcf494 100644 --- a/example/vite-app/package.json +++ b/example/vite-app/package.json @@ -1,17 +1,16 @@ { - "name": "vite-example", "private": true, - "version": "0.1.0", + "type": "module", "scripts": { "dev": "vite", "build": "vite build", - "preview": "vite preview" + "types:check": "tsc --noEmit" }, "devDependencies": { + "fastapi-vite-plugin": "^0.0.3", + "@tailwindcss/vite": "^4.0.0", + "tailwindcss": "^4.0.0", + "typescript": "^5.0.0", "vite": "^8.0.0" - }, - "dependencies": { - "@tailwindcss/vite": "^4.2.4", - "fastapi-vite-plugin": "^0.0.3" } -} +} \ No newline at end of file diff --git a/example/vite-app/resources/css/app.css b/example/vite-app/resources/css/app.css index 1ba54aeb..f1d8c73c 100644 --- a/example/vite-app/resources/css/app.css +++ b/example/vite-app/resources/css/app.css @@ -1,104 +1 @@ -*, *::before, *::after { - box-sizing: border-box; - margin: 0; - padding: 0; -} - -body { - font-family: system-ui, -apple-system, sans-serif; - background: #0f172a; - color: #e2e8f0; - min-height: 100vh; - display: flex; - align-items: center; - justify-content: center; -} - -.card { - background: #1e293b; - border: 1px solid #334155; - border-radius: 12px; - padding: 2.5rem 3rem; - max-width: 480px; - width: 100%; - text-align: center; - box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); -} - -.badge { - display: inline-flex; - align-items: center; - gap: 0.4rem; - background: #0ea5e9; - color: #fff; - font-size: 0.75rem; - font-weight: 600; - letter-spacing: 0.05em; - text-transform: uppercase; - padding: 0.25rem 0.75rem; - border-radius: 9999px; - margin-bottom: 1.25rem; -} - -h1 { - font-size: 1.75rem; - font-weight: 700; - margin-bottom: 0.75rem; - color: #f1f5f9; -} - -p { - color: #94a3b8; - line-height: 1.6; - margin-bottom: 1.5rem; -} - -.links { - display: flex; - gap: 0.75rem; - justify-content: center; - flex-wrap: wrap; -} - -.links a { - color: #38bdf8; - text-decoration: none; - font-size: 0.875rem; - padding: 0.4rem 1rem; - border: 1px solid #334155; - border-radius: 6px; - transition: border-color 0.2s, color 0.2s; -} - -.links a:hover { - border-color: #38bdf8; - color: #fff; -} - -#counter { - margin: 1.25rem 0; -} - -#counter button { - background: #0ea5e9; - color: #fff; - border: none; - border-radius: 6px; - padding: 0.5rem 1.25rem; - font-size: 0.9rem; - cursor: pointer; - transition: background 0.2s; -} - -#counter button:hover { - background: #0284c7; -} - -#counter span { - display: inline-block; - min-width: 2rem; - font-weight: 700; - font-size: 1.1rem; - vertical-align: middle; - margin: 0 0.5rem; -} \ No newline at end of file +@import "tailwindcss"; diff --git a/example/vite-app/resources/js/app.js b/example/vite-app/resources/js/app.js deleted file mode 100644 index 59934c08..00000000 --- a/example/vite-app/resources/js/app.js +++ /dev/null @@ -1,14 +0,0 @@ -import '../css/app.css' - -const btn = document.querySelector('#counter button') -const display = document.querySelector('#counter span') - -if (btn && display) { - let count = 0 - btn.addEventListener('click', () => { - count++ - display.textContent = count - }) -} - -console.log('[vite-example] app.js loaded') diff --git a/example/vite-app/resources/js/app.ts b/example/vite-app/resources/js/app.ts new file mode 100644 index 00000000..2f434421 --- /dev/null +++ b/example/vite-app/resources/js/app.ts @@ -0,0 +1,23 @@ +import '../css/app.css'; + +document.addEventListener('DOMContentLoaded', () => { + let count: number = 0; + const incrementBtn = document.querySelector('#increment'); + const decrementBtn = document.querySelector('#decrement'); + const display = document.querySelector('#count'); + + if (display) { + if (incrementBtn) { + incrementBtn.addEventListener('click', () => { + count++; + display.textContent = count.toString(); + }); + } + if (decrementBtn) { + decrementBtn.addEventListener('click', () => { + count--; + display.textContent = count.toString(); + }); + } + } +}); diff --git a/example/vite-app/templates/index.html b/example/vite-app/templates/index.html index c17b11b3..aa289235 100644 --- a/example/vite-app/templates/index.html +++ b/example/vite-app/templates/index.html @@ -4,26 +4,56 @@ FastAPI + Vite - {{ vite('resources/js/app.js') }} + {{ vite('resources/js/app.ts') }} - -
- ⚡ Vite + FastAPI -

Hello from FastAPI StartKit

-

- Assets are served via the Vite helper. - In development, HMR is active. In production, hashed files - are loaded from public/build/. + +

+
+ ⚡ Vite + FastAPI +
+ +

+ FastAPI StartKit +

+ +

+ Interactive counter demo with HMR and Tailwind CSS.

-
- - 0 + +
+
0
+
+ + +
+
+ +
+
+
HMR
+ Edit this file to see instant updates. +
+
+
Bundling
+ Assets are optimized for production. +
- - \ No newline at end of file + diff --git a/example/vite-app/tsconfig.json b/example/vite-app/tsconfig.json new file mode 100644 index 00000000..ebe4d31a --- /dev/null +++ b/example/vite-app/tsconfig.json @@ -0,0 +1,115 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Modules */ + "module": "ESNext" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */, + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + "noEmit": true /* Disable emitting files from a compilation. */, + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */, + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */, + "baseUrl": ".", + "paths": { + "@/*": [ + "./resources/js/*" + ] + }, + "jsx": "react-jsx" + }, + "include": [ + "resources/js/**/*.ts", + "resources/js/**/*.d.ts", + "resources/js/**/*.tsx" + ] +} \ No newline at end of file diff --git a/example/vite-app/vite.config.js b/example/vite-app/vite.config.ts similarity index 86% rename from example/vite-app/vite.config.js rename to example/vite-app/vite.config.ts index 9ac4395e..984be2b8 100644 --- a/example/vite-app/vite.config.js +++ b/example/vite-app/vite.config.ts @@ -5,7 +5,7 @@ import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ plugins: [ fastapi({ - input: "resources/js/app.js", + input: "resources/js/app.ts", refresh: true, }), tailwindcss() diff --git a/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py b/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py index 927b7794..451e0500 100644 --- a/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py +++ b/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py @@ -45,10 +45,12 @@ def boot(self) -> None: self.publishes( { - os.path.join(stubs_path, "vite.config.js"): "vite.config.js", + os.path.join(stubs_path, "vite.config.ts"): "vite.config.ts", os.path.join(stubs_path, "package.json"): "package.json", - os.path.join(stubs_path, "resources/js/app.js"): "resources/js/app.js", + os.path.join(stubs_path, "tsconfig.json"): "tsconfig.json", + os.path.join(stubs_path, "resources/js/app.ts"): "resources/js/app.ts", os.path.join(stubs_path, "resources/css/app.css"): "resources/css/app.css", + os.path.join(stubs_path, "templates/index.html"): "templates/index.html", } ) diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/package.json b/fastapi_startkit/src/fastapi_startkit/vite/stubs/package.json index df892ce5..addcf494 100644 --- a/fastapi_startkit/src/fastapi_startkit/vite/stubs/package.json +++ b/fastapi_startkit/src/fastapi_startkit/vite/stubs/package.json @@ -3,12 +3,14 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vite build" + "build": "vite build", + "types:check": "tsc --noEmit" }, "devDependencies": { "fastapi-vite-plugin": "^0.0.3", "@tailwindcss/vite": "^4.0.0", "tailwindcss": "^4.0.0", + "typescript": "^5.0.0", "vite": "^8.0.0" } } \ No newline at end of file diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/css/app.css b/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/css/app.css index 810bd069..f1d8c73c 100644 --- a/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/css/app.css +++ b/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/css/app.css @@ -1,4 +1 @@ -/* resources/css/app.css */ -body { - background-color: #f3f4f6; -} +@import "tailwindcss"; diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.js b/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.js deleted file mode 100644 index b6754616..00000000 --- a/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.js +++ /dev/null @@ -1,3 +0,0 @@ -import '../css/app.css'; - -console.log('Vite is running!'); diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.ts b/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.ts new file mode 100644 index 00000000..2f434421 --- /dev/null +++ b/fastapi_startkit/src/fastapi_startkit/vite/stubs/resources/js/app.ts @@ -0,0 +1,23 @@ +import '../css/app.css'; + +document.addEventListener('DOMContentLoaded', () => { + let count: number = 0; + const incrementBtn = document.querySelector('#increment'); + const decrementBtn = document.querySelector('#decrement'); + const display = document.querySelector('#count'); + + if (display) { + if (incrementBtn) { + incrementBtn.addEventListener('click', () => { + count++; + display.textContent = count.toString(); + }); + } + if (decrementBtn) { + decrementBtn.addEventListener('click', () => { + count--; + display.textContent = count.toString(); + }); + } + } +}); diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/templates/index.html b/fastapi_startkit/src/fastapi_startkit/vite/stubs/templates/index.html new file mode 100644 index 00000000..aa289235 --- /dev/null +++ b/fastapi_startkit/src/fastapi_startkit/vite/stubs/templates/index.html @@ -0,0 +1,59 @@ + + + + + + FastAPI + Vite + {{ vite('resources/js/app.ts') }} + + +
+
+ ⚡ Vite + FastAPI +
+ +

+ FastAPI StartKit +

+ +

+ Interactive counter demo with HMR and Tailwind CSS. +

+ +
+
0
+
+ + +
+
+ +
+
+
HMR
+ Edit this file to see instant updates. +
+
+
Bundling
+ Assets are optimized for production. +
+
+ +
+ Powered by FastAPI StartKit +
+
+ + diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/tsconfig.json b/fastapi_startkit/src/fastapi_startkit/vite/stubs/tsconfig.json new file mode 100644 index 00000000..ebe4d31a --- /dev/null +++ b/fastapi_startkit/src/fastapi_startkit/vite/stubs/tsconfig.json @@ -0,0 +1,115 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Modules */ + "module": "ESNext" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */, + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + "noEmit": true /* Disable emitting files from a compilation. */, + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */, + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */, + "baseUrl": ".", + "paths": { + "@/*": [ + "./resources/js/*" + ] + }, + "jsx": "react-jsx" + }, + "include": [ + "resources/js/**/*.ts", + "resources/js/**/*.d.ts", + "resources/js/**/*.tsx" + ] +} \ No newline at end of file diff --git a/fastapi_startkit/src/fastapi_startkit/vite/stubs/vite.config.js b/fastapi_startkit/src/fastapi_startkit/vite/stubs/vite.config.ts similarity index 86% rename from fastapi_startkit/src/fastapi_startkit/vite/stubs/vite.config.js rename to fastapi_startkit/src/fastapi_startkit/vite/stubs/vite.config.ts index 9ac4395e..984be2b8 100644 --- a/fastapi_startkit/src/fastapi_startkit/vite/stubs/vite.config.js +++ b/fastapi_startkit/src/fastapi_startkit/vite/stubs/vite.config.ts @@ -5,7 +5,7 @@ import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ plugins: [ fastapi({ - input: "resources/js/app.js", + input: "resources/js/app.ts", refresh: true, }), tailwindcss() diff --git a/fastapi_startkit/src/fastapi_startkit/vite/vite.py b/fastapi_startkit/src/fastapi_startkit/vite/vite.py index 95155597..8f2a8e9a 100644 --- a/fastapi_startkit/src/fastapi_startkit/vite/vite.py +++ b/fastapi_startkit/src/fastapi_startkit/vite/vite.py @@ -20,7 +20,7 @@ class Vite: Typical usage in a Jinja2 template:: - {{ vite('resources/js/app.js') }} + {{ vite('resources/js/app.ts') }} {{ vite_asset('resources/images/logo.png') }} {{ vite_react_refresh() }} """