wxt
wxt copied to clipboard
Nested unlisted pages?
Is it possible to nest unlisted page in some folder? E.g. I want to include auth in my extension, so I want to add auth folder and inside it define all the routes, how can I do it?
.
├── src
│ ├── entrypoints
│ │ ├── auth
│ │ │ ├──index.html
│ │ │ ├──main.ts
├── package.json
- index.html
<script type="module" src="./main.ts"></script>
. ├── src │ ├── entrypoints │ │ ├── auth │ │ │ ├──index.html │ │ │ ├──main.ts ├── package.json
- index.html
<script type="module" src="./main.ts"></script>
Yes, that's good, but I want to nest pages under auth e.g. /auth/login or /auth/register
Yes, that's good, but I want to nest pages under auth e.g.
/auth/loginor/auth/register
.
├── src
│ ├── entrypoints
│ │ ├── auth
│ │ │ ├──login
│ │ │ │ ├──index.html
│ │ │ ├──register
│ │ │ │ ├──index.html
│ ├── modules
│ │ │ ├──my-entrypoints.ts // filename doesn't matter
├── package.json
- my-entrypoints.ts
This is a hard-coded example, implement the effect of glob by yourself.
import { resolve } from "node:path";
import { addEntrypoint, defineWxtModule } from "wxt/modules";
export default defineWxtModule(wxt => {
addEntrypoint(wxt, {
type: "unlisted-page",
name: "auth/login",
inputPath: resolve(wxt.config.entrypointsDir, "auth/login/index.html"),
outputDir: resolve(wxt.config.outDir),
skipped: false,
options: {}
});
addEntrypoint(wxt, {
type: "unlisted-page",
name: "auth/register",
inputPath: resolve(wxt.config.entrypointsDir, "auth/register/index.html"),
outputDir: resolve(wxt.config.outDir),
skipped: false,
options: {}
});
});