path-rush 1.3.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 da-b1rmuda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # Path Rush
2
+ **File-Based Routing for Vite**
3
+
4
+ 📘 **Documentation:** https://path-rush.web2bizz.ru/
5
+
6
+ Path Rush is a Vite plugin that provides file-based routing for React applications.
7
+ It is inspired by Next.js and designed to be lightweight, predictable, and production-ready.
8
+
9
+ The plugin enables automatic route generation from the file system, supports layouts, dynamic routes, HMR, SEO integration, and TypeScript type generation with minimal configuration.
10
+
11
+ ---
12
+
13
+ ## Key Features
14
+
15
+ - File-based routing using the filesystem
16
+ - Nested layout support
17
+ - Dynamic and catch-all routes
18
+ - Hot Module Replacement (HMR)
19
+ - Automatic sitemap.xml and robots.txt generation
20
+ - SEO metadata extraction
21
+ - Code splitting and lazy loading
22
+ - Full TypeScript support with autogenerated types
23
+ - Multiple frontends on a single domain via base paths
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install path-rush
31
+ # or
32
+ pnpm add path-rush
33
+ # or
34
+ yarn add path-rush
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Quick Start
40
+
41
+ ### 1. Vite Configuration
42
+
43
+ ```ts
44
+ // vite.config.ts
45
+ import { defineConfig } from 'vite'
46
+ import react from '@vitejs/plugin-react'
47
+ import { pathRush } from 'path-rush/core'
48
+
49
+ export default defineConfig({
50
+ plugins: [react(), pathRush()],
51
+ })
52
+ ```
53
+
54
+ ---
55
+
56
+ ### 2. Pages Structure
57
+
58
+ ```txt
59
+ src/pages/
60
+ ├── page.tsx // /
61
+ ├── about/page.tsx // /about
62
+ ├── blog/
63
+ │ ├── page.tsx // /blog
64
+ │ └── [id]/page.tsx // /blog/:id
65
+ ├── layout.tsx // Root layout
66
+ ├── (auth)/login/page.tsx // /login
67
+ └── _components/ // Ignored
68
+ ```
69
+
70
+ **Rules:**
71
+
72
+ - Folders wrapped in parentheses are route groups and do not appear in the URL
73
+ - Files and folders starting with `_` are ignored by the router
74
+
75
+ ---
76
+
77
+ ### 3. Page Example
78
+
79
+ ```tsx
80
+ export default function HomePage() {
81
+ return <h1>Home</h1>
82
+ }
83
+
84
+ export const metadata = {
85
+ title: 'Home',
86
+ description: 'Welcome to the website',
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ### 4. Layout Example
93
+
94
+ ```tsx
95
+ export default function RootLayout({
96
+ children,
97
+ }: {
98
+ children: React.ReactNode
99
+ }) {
100
+ return (
101
+ <>
102
+ <header>Header</header>
103
+ <main>{children}</main>
104
+ <footer>Footer</footer>
105
+ </>
106
+ )
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ### 5. Router Provider
113
+
114
+ ```tsx
115
+ // main.tsx
116
+ import { RouterProvider } from 'path-rush/react'
117
+
118
+ ReactDOM.createRoot(document.getElementById('root')!).render(
119
+ <RouterProvider />
120
+ )
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Configuration
126
+
127
+ ```ts
128
+ pathRush({
129
+ pagesDir: 'src/pages',
130
+ pageFileName: 'page',
131
+ layoutFileName: 'layout',
132
+ extensions: ['tsx', 'jsx'],
133
+ baseUrl: 'https://example.com',
134
+ basePath: '/',
135
+ enableSEO: true,
136
+ generateTypes: true,
137
+ })
138
+ ```
139
+
140
+ The plugin automatically configures the required Vite options.
141
+ No additional setup is needed.
142
+
143
+ ---
144
+
145
+ ## SEO Support
146
+
147
+ Path Rush extracts metadata from:
148
+
149
+ - JSDoc comments
150
+ - `export const metadata`
151
+
152
+ Based on this data, the plugin generates:
153
+
154
+ - `sitemap.xml`
155
+ - `robots.txt`
156
+ - strongly typed metadata definitions for TypeScript
157
+
158
+ ---
159
+
160
+ ## Production Build
161
+
162
+ During production builds, Path Rush automatically enables:
163
+
164
+ - route-based code splitting
165
+ - lazy loading for pages and layouts
166
+ - route manifest generation
167
+ - TypeScript route and metadata types
168
+
169
+ ```txt
170
+ dist/
171
+ ├── routes-manifest.js
172
+ ├── sitemap.xml
173
+ ├── robots.txt
174
+ └── types/
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Multiple Frontends
180
+
181
+ Path Rush supports multiple frontend applications on a single domain using `basePath`.
182
+
183
+ Example:
184
+ - `/` — main application
185
+ - `/admin` — admin panel
186
+
187
+ Each frontend should have its own `pagesDir` and entry point.
188
+
189
+ ---
190
+
191
+ ## License
192
+
193
+ MIT License
194
+ © da-b1rmuda
195
+ Web2Bizz