Skip to content

Commit

Permalink
feat: add project templating and javascript plugin
Browse files Browse the repository at this point in the history
feat: add project templating and javascript plugin
  • Loading branch information
cofin authored Dec 10, 2023
2 parents 9f13da0 + c2f6d73 commit b056c42
Show file tree
Hide file tree
Showing 45 changed files with 2,623 additions and 687 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,5 @@ cython_debug/

# vscode
.vscode

node_modules
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ default_language_version:
python: "3.11"
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.4.0
rev: v3.0.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -17,7 +17,7 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.292"
rev: "v0.1.7"
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -27,12 +27,12 @@ repos:
hooks:
- id: codespell
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.11.0
hooks:
- id: black
args: [--config=./pyproject.toml]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.1"
rev: "v1.7.1"
hooks:
- id: mypy
exclude: "docs"
Expand All @@ -52,6 +52,6 @@ repos:
"litestar[cli]",
]
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: "v0.6.8"
rev: "v0.9.0"
hooks:
- id: sphinx-lint
Empty file added examples/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions examples/htmx/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations

from pathlib import Path

from litestar import Litestar

from litestar_vite import ViteConfig, VitePlugin

here = Path(__file__).parent

vite = VitePlugin(
config=ViteConfig(
bundle_dir=Path(here / "web" / "public"),
resource_dir=Path(here / "web" / "resources"),
assets_dir=Path(here / "web" / "resources" / "assets"),
templates_dir=Path(here / "web" / "templates"),
hot_reload=True,
),
)
app = Litestar(plugins=[vite])
20 changes: 20 additions & 0 deletions examples/htmx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"htmx.org": "^1.9.6"
},
"devDependencies": {
"axios": "^1.1.2",
"litestar-vite-plugin": "^0.1.0",
"typescript": "^4.9.5",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.31",
"tailwindcss": "^3.3.5",
"vite": "^4.0.0"
}
}
31 changes: 31 additions & 0 deletions examples/htmx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true,
"composite": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "resources",
"paths": {
"@/*": ["./*"]
},
"types": ["vite/client", "node"]
},
"include": [
"**/*.d.ts",
"resources/**/*.js" ,
"resources/**/*.ts" ,


"vite.config.ts"
]
}
25 changes: 25 additions & 0 deletions examples/htmx/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig } from "vite";


import litestar from "litestar-vite-plugin";

export default defineConfig({
plugins: [


litestar({
input: [
"resources/styles.css"
],
assetUrl: "/static/",
assetDirectory: "resources/assets",
bundleDirectory: "public",
resourceDirectory: "resources"
}),
],
resolve: {
alias: {
"@": "resources",
},
},
});
20 changes: 20 additions & 0 deletions examples/react/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations

from pathlib import Path

from litestar import Litestar

from litestar_vite import ViteConfig, VitePlugin

here = Path(__file__).parent

vite = VitePlugin(
config=ViteConfig(
bundle_dir=Path(here / "web" / "public"),
resource_dir=Path(here / "web" / "resources"),
assets_dir=Path(here / "web" / "resources" / "assets"),
templates_dir=Path(here / "web" / "templates"),
hot_reload=True,
),
)
app = Litestar(plugins=[vite])
Empty file added examples/vue/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions examples/vue/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import annotations

from pathlib import Path

from litestar import Litestar
from web.controllers import WebController

from litestar_vite import ViteConfig, VitePlugin

here = Path(__file__).parent

vite = VitePlugin(
config=ViteConfig(
bundle_dir=Path(here / "web" / "public"),
resource_dir=Path(here / "web" / "resources"),
assets_dir=Path(here / "web" / "resources" / "assets"),
templates_dir=Path(here / "web" / "templates"),
hot_reload=True,
port=3006,
),
)
app = Litestar(plugins=[vite], route_handlers=[WebController])
Loading

0 comments on commit b056c42

Please sign in to comment.