Skip to content

Commit

Permalink
feat: adds 404 redirect option (#46)
Browse files Browse the repository at this point in the history
* feat: adds 404 redirect option

* fix: various typing improvements to `vite-plugin`
  • Loading branch information
cofin authored Dec 1, 2024
1 parent 4d28bb1 commit 999abae
Show file tree
Hide file tree
Showing 36 changed files with 2,267 additions and 4,279 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ repos:
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
- repo: local
hooks:
- id: local-biome-check
name: biome check
entry: npx biome check --write --files-ignore-unknown=true --no-errors-on-unmatched
language: system
types: [text]
files: "\\.(jsx?|tsx?|c(js|ts)|m(js|ts)|d\\.(ts|cts|mts)|jsonc?|css|svelte|vue|astro|graphql|gql)$"
exclude: templates|migrations|scripts|docs|dist|.venv|public|node_modules
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ install: destroy clean ## Install the project, dependencies, and pre-comm
@uv python pin 3.12
@uv venv
@uv sync --all-extras --dev
@uvx nodeenv .venv --force --quiet
@if ! command -v npm >/dev/null 2>&1; then \
uvx nodeenv .venv --force --quiet; \
fi
@npm install
@echo "=> Install complete!"

Expand All @@ -48,16 +50,14 @@ upgrade: ## Upgrade all dependencies to the latest stable versio
.PHONY: clean
clean: ## Cleanup temporary build artifacts
@echo "=> Cleaning working directory"
@rm -rf .pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/
@rm -rf pytest_cache .ruff_cache .hypothesis build/ -rf dist/ .eggs/ .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/**/.pytest_cache .mypy_cache .unasyncd_cache/ .auto_pytabs_cache node_modules
@find . -name '*.egg-info' -exec rm -rf {} +
@find . -type f -name '*.egg' -exec rm -f {} +
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@find . -name '*~' -exec rm -f {} +
@find . -name '__pycache__' -exec rm -rf {} +
@find . -name '.ipynb_checkpoints' -exec rm -rf {} +
@rm -rf .coverage coverage.xml coverage.json htmlcov/ .pytest_cache tests/.pytest_cache tests/**/.pytest_cache .mypy_cache .unasyncd_cache/
@rm -rf node_modules
$(MAKE) docs-clean

.PHONY: destroy
Expand Down
51 changes: 51 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"organizeImports": {
"enabled": true,
"ignore": ["node_modules", "dist", "out", ".venv", "public", "src/py"]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 180,
"lineEnding": "lf",
"ignore": ["node_modules", "dist", "out", ".next", "public", "src/py"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"complexity": {
"noForEach": "off"
},
"a11y": {
"noSvgWithoutTitle": "off"
},
"nursery": {
"useSortedClasses": "warn"
}
},
"ignore": ["node_modules", "dist", "out", ".next", "public"]
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"jsxQuoteStyle": "double",
"semicolons": "asNeeded"
}
},
"files": {
"ignore": ["**/node_modules", "**/dist", "CHANGELOG.md", "package-lock.json", "pnpm-lock.yaml", ".venv", "out", "src/py"]
}
}
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import annotations

import os
from typing import Any

from litestar_vite.__metadata__ import __project__, __version__

Expand Down Expand Up @@ -124,7 +125,7 @@
"--brand-light": {"rgb": "235, 221, 221", "hex": "#ebdddd"},
}

html_theme_options = {
html_theme_options: dict[str, Any] = {
# "logo_target": "/",
# "github_url": "https://github.com/litestar-org/litestar-vite",
# "github_repo_name": "Litestar Vite",
Expand Down
18 changes: 9 additions & 9 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"watch": "vite build --watch",
"build": "vite build"
},
"dependencies": {"axios":"^1.7.4"},
"devDependencies": {"typescript":"^5.3.3","vite":"^5.0.6","litestar-vite-plugin":"^0.5.1","@types/node":"^20.10.3"}
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"watch": "vite build --watch",
"build": "vite build"
},
"dependencies": { "axios": "^1.7.4" },
"devDependencies": { "typescript": "^5.3.3", "vite": "^5.0.6", "litestar-vite-plugin": "^0.5.1", "@types/node": "^20.10.3" }
}
25 changes: 10 additions & 15 deletions examples/basic/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { defineConfig } from "vite";
import { defineConfig } from "vite"

import litestar from "litestar-vite-plugin"

import litestar from "litestar-vite-plugin";

const ASSET_URL = process.env.ASSET_URL || "/static/";
const VITE_PORT = process.env.VITE_PORT || "5173";
const VITE_HOST = process.env.VITE_HOST || "localhost";
const ASSET_URL = process.env.ASSET_URL || "/static/"
const VITE_PORT = process.env.VITE_PORT || "5173"
const VITE_HOST = process.env.VITE_HOST || "localhost"
export default defineConfig({
base: `${ASSET_URL}`,
root: ".",
root: ".",
server: {
host: "0.0.0.0",
port: +`${VITE_PORT}`,
Expand All @@ -18,21 +17,17 @@ export default defineConfig({
},
},
plugins: [


litestar({
input: [
"resources/main.ts", "resources/styles.css"
],
input: ["resources/main.ts", "resources/styles.css"],
assetUrl: `${ASSET_URL}`,
bundleDirectory: "public",
resourceDirectory: "resources",
hotFile: "public/hot"
hotFile: "public/hot",
}),
],
resolve: {
alias: {
"@": "resources"
"@": "resources",
},
},
});
})
18 changes: 9 additions & 9 deletions examples/flash/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"watch": "vite build --watch",
"build": "vite build"
},
"dependencies": {"axios":"^1.7.4"},
"devDependencies": {"typescript":"^5.3.3","vite":"^5.4.11","litestar-vite-plugin":"^0.5.1","@types/node":"^20.10.3"}
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"watch": "vite build --watch",
"build": "vite build"
},
"dependencies": { "axios": "^1.7.4" },
"devDependencies": { "typescript": "^5.3.3", "vite": "^5.4.11", "litestar-vite-plugin": "^0.5.1", "@types/node": "^20.10.3" }
}
8 changes: 1 addition & 7 deletions examples/flash/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,5 @@
},
"types": ["vite/client"]
},
"include": [

"**/*.d.ts",
"resources/**/*.js" ,
"resources/**/*.ts" ,
"vite.config.ts"
]
"include": ["**/*.d.ts", "resources/**/*.js", "resources/**/*.ts", "vite.config.ts"]
}
25 changes: 10 additions & 15 deletions examples/flash/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { defineConfig } from "vite";
import { defineConfig } from "vite"

import litestar from "litestar-vite-plugin"

import litestar from "litestar-vite-plugin";

const ASSET_URL = process.env.ASSET_URL || "/static/";
const VITE_PORT = process.env.VITE_PORT || "5173";
const VITE_HOST = process.env.VITE_HOST || "localhost";
const ASSET_URL = process.env.ASSET_URL || "/static/"
const VITE_PORT = process.env.VITE_PORT || "5173"
const VITE_HOST = process.env.VITE_HOST || "localhost"
export default defineConfig({
base: `${ASSET_URL}`,
root: ".",
root: ".",
server: {
host: "0.0.0.0",
port: +`${VITE_PORT}`,
Expand All @@ -18,21 +17,17 @@ export default defineConfig({
},
},
plugins: [


litestar({
input: [
"resources/main.ts", "resources/styles.css"
],
input: ["resources/main.ts", "resources/styles.css"],
assetUrl: `${ASSET_URL}`,
bundleDirectory: "public",
resourceDirectory: "resources",
hotFile: "public/hot"
hotFile: "public/hot",
}),
],
resolve: {
alias: {
"@": "resources"
"@": "resources",
},
},
});
})
2 changes: 1 addition & 1 deletion examples/inertia/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
};
}
2 changes: 1 addition & 1 deletion examples/inertia/resources/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { Link } from "@inertiajs/vue3";
import { Link } from "@inertiajs/vue3"
</script>

<template>
Expand Down
18 changes: 9 additions & 9 deletions examples/inertia/resources/main.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/vue3";
import Layout from "./Layout.vue";
import { createInertiaApp } from "@inertiajs/vue3"
import { createApp, h } from "vue"
import Layout from "./Layout.vue"
createInertiaApp({
resolve: (name) => {
const pages = import.meta.glob("./pages/**/*.vue", {
eager: true,
});
let page = pages[`./pages/${name}.vue`];
page.default.layout = page.default.layout || Layout;
return page;
})
const page = pages[`./pages/${name}.vue`]
page.default.layout = page.default.layout || Layout
return page
},
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.mount(el);
.mount(el)
},
});
})
4 changes: 2 additions & 2 deletions examples/inertia/resources/pages/Dashboard.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup>
import { Head, Link } from "@inertiajs/vue3";
import { Head, Link } from "@inertiajs/vue3"
defineProps({
content: {
message: String,
},
});
})
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions examples/inertia/resources/pages/Home.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup>
import { Head, Link } from "@inertiajs/vue3";
import { Head, Link } from "@inertiajs/vue3"
defineProps({
content: {
message: String,
},
});
})
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion examples/inertia/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module.exports = {
extend: {},
},
plugins: [],
};
}
7 changes: 1 addition & 6 deletions examples/inertia/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@
},
"types": ["vite/client"]
},
"include": [
"**/*.d.ts",
"resources/**/*.js",
"resources/**/*.ts",
"vite.config.js"
]
"include": ["**/*.d.ts", "resources/**/*.js", "resources/**/*.ts", "vite.config.js"]
}
14 changes: 7 additions & 7 deletions examples/inertia/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import litestar from "litestar-vite-plugin";
import vue from "@vitejs/plugin-vue"
import litestar from "litestar-vite-plugin"
import { defineConfig } from "vite"

const ASSET_URL = process.env.ASSET_URL || "/static/";
const VITE_PORT = process.env.VITE_PORT || "5173";
const VITE_HOST = process.env.VITE_HOST || "localhost";
const ASSET_URL = process.env.ASSET_URL || "/static/"
const VITE_PORT = process.env.VITE_PORT || "5173"
const VITE_HOST = process.env.VITE_HOST || "localhost"
export default defineConfig({
base: `${ASSET_URL}`,
root: ".",
Expand Down Expand Up @@ -38,4 +38,4 @@ export default defineConfig({
"@": "resources",
},
},
});
})
Loading

0 comments on commit 999abae

Please sign in to comment.