generated from sergiodxa/package
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,51 @@ | ||
# package | ||
# remix-define-routes | ||
|
||
A template to create new packages. | ||
A DSL to define Remix routes with code. | ||
|
||
## Setup | ||
|
||
```bash | ||
npm add remix-define-routes | ||
``` | ||
|
||
Create a file called `routes.ts` in your Remix project. | ||
|
||
```ts | ||
import { defineRoutes } from "remix-define-routes"; | ||
|
||
let authRoutes = defineRoutes(({ layout }) => { | ||
layout("auth", { base: "routes/auth" }, ({ route }) => { | ||
route("index", "routes/auth._index"); | ||
route("register"); | ||
route("login"); | ||
}); | ||
}); | ||
|
||
export default defineRoutes(({ route, extend }) => { | ||
extend(authRoutes); | ||
|
||
route("api/healthcheck"); | ||
route("index", "routes/_index"); | ||
route("admin/:resource"); | ||
}); | ||
``` | ||
|
||
Then in your `vite.config.ts` import and use it to configure your Remix plugin. | ||
|
||
```ts | ||
import { vitePlugin as remix } from "@remix-run/dev"; | ||
import { defineConfig } from "vite"; | ||
|
||
import routes from "./config/routes"; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
remix({ | ||
ignoredRouteFiles: ["**/*"], | ||
routes: () => routes, | ||
}), | ||
], | ||
}); | ||
``` | ||
|
||
And now you can use route routes file to define your application routes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters