netjes 0.0.5 → 0.0.6
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/README.md +12 -8
- package/cli/commands.mjs +62 -9
- package/cli/process-io.mjs +2 -2
- package/cli/scaffold.mjs +89 -8
- package/dist/client-entry.js +4 -1
- package/dist/client-entry.js.map +1 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1 -1
- package/dist/document.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/locale.d.ts +5 -0
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +4 -0
- package/dist/locale.js.map +1 -1
- package/dist/metadata.d.ts +81 -4
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +129 -7
- package/dist/metadata.js.map +1 -1
- package/dist/modules.d.ts +6 -1
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +15 -1
- package/dist/modules.js.map +1 -1
- package/dist/offline.d.ts +11 -0
- package/dist/offline.d.ts.map +1 -0
- package/dist/offline.js +98 -0
- package/dist/offline.js.map +1 -0
- package/dist/payload.d.ts +18 -0
- package/dist/payload.d.ts.map +1 -1
- package/dist/payload.js +29 -6
- package/dist/payload.js.map +1 -1
- package/dist/render-document.d.ts +8 -1
- package/dist/render-document.d.ts.map +1 -1
- package/dist/render-document.js +2 -0
- package/dist/render-document.js.map +1 -1
- package/dist/root.d.ts.map +1 -1
- package/dist/root.js +9 -1
- package/dist/root.js.map +1 -1
- package/dist/route-tree.d.ts +2 -1
- package/dist/route-tree.d.ts.map +1 -1
- package/dist/route-tree.js +14 -7
- package/dist/route-tree.js.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1 -1
- package/dist/router.js.map +1 -1
- package/dist/service-worker.d.ts +81 -0
- package/dist/service-worker.d.ts.map +1 -0
- package/dist/service-worker.js +584 -0
- package/dist/service-worker.js.map +1 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js.map +1 -1
- package/package.json +12 -5
- package/sidecar/server.mjs +25 -2
- package/skills/netjes/SKILL.md +3 -1
- package/skills/netjes/references/caching-and-streaming.md +22 -1
- package/skills/netjes/references/deployment.md +2 -2
- package/skills/netjes/references/routing.md +5 -1
- package/src/client-entry.tsx +4 -1
- package/src/document.tsx +6 -1
- package/src/index.ts +3 -2
- package/src/locale.ts +5 -0
- package/src/metadata.tsx +207 -11
- package/src/modules.ts +19 -3
- package/src/offline.ts +97 -0
- package/src/payload.ts +41 -5
- package/src/render-document.tsx +10 -1
- package/src/root.tsx +21 -11
- package/src/route-tree.tsx +18 -7
- package/src/router.tsx +1 -0
- package/src/service-worker.ts +632 -0
- package/src/testing.tsx +1 -0
- package/template/Dockerfile.pnpm +68 -0
- package/template/Dockerfile.workspace +52 -0
- package/template/Dockerfile.workspace.dockerignore +15 -0
- package/template/README.md +5 -1
- package/template/_AGENTS.md +5 -1
- package/template/app/layout.tsx +0 -1
- package/tsconfig.strict-app.json +27 -0
- package/vite/packages.mjs +97 -0
- package/vite/plugin.d.ts +8 -1
- package/vite/plugin.mjs +156 -9
- /package/template/{public/favicon.svg → app/icon.svg} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
# Build from the app folder: docker build .
|
|
3
|
+
# From a Netjes checkout, scaffold with --packages to use published packages in Docker.
|
|
4
|
+
ARG NODE_IMAGE=node:24.22.1-bookworm-slim
|
|
5
|
+
ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0.403-noble
|
|
6
|
+
ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0.14-noble
|
|
7
|
+
|
|
8
|
+
FROM ${NODE_IMAGE} AS node
|
|
9
|
+
|
|
10
|
+
FROM node AS deps
|
|
11
|
+
WORKDIR /src
|
|
12
|
+
RUN npm install --global pnpm@10.28.2
|
|
13
|
+
COPY package.json pnpm-lock.yaml ./
|
|
14
|
+
RUN pnpm install --frozen-lockfile
|
|
15
|
+
|
|
16
|
+
# netjes:if compose
|
|
17
|
+
# Development: the source is bind-mounted by docker-compose.override.yml.
|
|
18
|
+
FROM ${SDK_IMAGE} AS dev
|
|
19
|
+
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
|
20
|
+
COPY --from=deps /usr/local/lib/node_modules/pnpm /usr/local/lib/node_modules/pnpm
|
|
21
|
+
RUN ln -s /usr/local/lib/node_modules/pnpm/bin/pnpm.cjs /usr/local/bin/pnpm
|
|
22
|
+
WORKDIR /src
|
|
23
|
+
COPY --from=deps /src ./
|
|
24
|
+
# The CLI defaults to localhost:5080 unless ASPNETCORE_URLS is set.
|
|
25
|
+
ENV ASPNETCORE_URLS=http://+:8080 \
|
|
26
|
+
ASPNETCORE_ENVIRONMENT=Development \
|
|
27
|
+
DOTNET_USE_POLLING_FILE_WATCHER=1 \
|
|
28
|
+
DOTNET_WATCH_SUPPRESS_BROWSER_REFRESH=1 \
|
|
29
|
+
NETJES_VITE_HOST=0.0.0.0
|
|
30
|
+
EXPOSE 8080 5173
|
|
31
|
+
CMD ["pnpm", "dev"]
|
|
32
|
+
|
|
33
|
+
# netjes:end
|
|
34
|
+
# Client bundle (dist/client) and server bundle + sidecar (dist/server).
|
|
35
|
+
FROM deps AS client
|
|
36
|
+
COPY . .
|
|
37
|
+
RUN pnpm run build
|
|
38
|
+
|
|
39
|
+
FROM ${SDK_IMAGE} AS build
|
|
40
|
+
WORKDIR /src
|
|
41
|
+
COPY __NAME__.csproj ./
|
|
42
|
+
RUN dotnet restore
|
|
43
|
+
COPY . .
|
|
44
|
+
COPY --from=client /src/dist dist
|
|
45
|
+
RUN dotnet publish -c Release -o /app --no-restore -p:NetjesSkipClientBuild=true
|
|
46
|
+
|
|
47
|
+
# tini, the production image's PID 1 (below): Ubuntu's package, installed in the SDK image the build stage uses. The
|
|
48
|
+
# production stage takes its static binary, which needs no package manager and no library in RUNTIME_IMAGE.
|
|
49
|
+
FROM ${SDK_IMAGE} AS tini
|
|
50
|
+
RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/*
|
|
51
|
+
|
|
52
|
+
# Production: ASP.NET Core runtime plus the node binary for the SSR sidecar. Runs as the non-root app user.
|
|
53
|
+
FROM ${RUNTIME_IMAGE} AS production
|
|
54
|
+
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
|
55
|
+
COPY --from=tini /usr/bin/tini-static /usr/bin/tini
|
|
56
|
+
# Mount a persistent volume here to keep ASP.NET Core Data Protection keys across container replacements.
|
|
57
|
+
RUN mkdir -p /home/app/.aspnet/DataProtection-Keys && chown -R app:app /home/app/.aspnet
|
|
58
|
+
WORKDIR /app
|
|
59
|
+
COPY --from=build /app ./
|
|
60
|
+
USER $APP_UID
|
|
61
|
+
EXPOSE 8080
|
|
62
|
+
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s --retries=3 \
|
|
63
|
+
CMD ["node", "-e", "fetch('http://127.0.0.1:8080/healthz').then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
|
|
64
|
+
# tini is PID 1 and runs the app as its child. The kernel ignores a signal that a container's PID 1 has no handler for,
|
|
65
|
+
# so an app that is PID 1 never dies of its own abort(): after a crash it spins (arm64) or exits with another code than
|
|
66
|
+
# 134. tini passes signals on (docker stop), reaps orphans and exits with the app's code; -s keeps it reaping when
|
|
67
|
+
# another process is PID 1, as under docker run --init.
|
|
68
|
+
ENTRYPOINT ["tini", "-s", "--", "dotnet", "__NAME__.dll"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# syntax=docker/dockerfile:1
|
|
2
|
+
# Build from the workspace root with -f pointing to this Dockerfile.
|
|
3
|
+
# From a Netjes checkout, scaffold with --packages to use published packages in Docker.
|
|
4
|
+
ARG NODE_IMAGE=node:24.22.1-bookworm-slim
|
|
5
|
+
ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0.403-noble
|
|
6
|
+
ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0.14-noble
|
|
7
|
+
|
|
8
|
+
FROM ${NODE_IMAGE} AS node
|
|
9
|
+
|
|
10
|
+
FROM node AS deps
|
|
11
|
+
ARG APP_DIR=__APP_DIR__
|
|
12
|
+
WORKDIR /src
|
|
13
|
+
RUN npm install --global pnpm@10.28.2
|
|
14
|
+
# Keep the workspace packages and any vendored tarballs in the build context.
|
|
15
|
+
COPY . .
|
|
16
|
+
RUN pnpm install --frozen-lockfile --filter "{./${APP_DIR}}..."
|
|
17
|
+
|
|
18
|
+
# Client bundle (dist/client) and server bundle + sidecar (dist/server).
|
|
19
|
+
FROM deps AS client
|
|
20
|
+
WORKDIR /src/${APP_DIR}
|
|
21
|
+
RUN pnpm run build
|
|
22
|
+
|
|
23
|
+
FROM ${SDK_IMAGE} AS build
|
|
24
|
+
ARG APP_DIR=__APP_DIR__
|
|
25
|
+
WORKDIR /src
|
|
26
|
+
COPY . .
|
|
27
|
+
WORKDIR /src/${APP_DIR}
|
|
28
|
+
COPY --from=client ["/src/${APP_DIR}/dist", "dist"]
|
|
29
|
+
RUN dotnet publish -c Release -o /app -p:NetjesSkipClientBuild=true
|
|
30
|
+
|
|
31
|
+
# tini, the production image's PID 1 (below): Ubuntu's package, installed in the SDK image the build stage uses. The
|
|
32
|
+
# production stage takes its static binary, which needs no package manager and no library in RUNTIME_IMAGE.
|
|
33
|
+
FROM ${SDK_IMAGE} AS tini
|
|
34
|
+
RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/*
|
|
35
|
+
|
|
36
|
+
# Production: ASP.NET Core runtime plus the node binary for the SSR sidecar. Runs as the non-root app user.
|
|
37
|
+
FROM ${RUNTIME_IMAGE} AS production
|
|
38
|
+
COPY --from=node /usr/local/bin/node /usr/local/bin/node
|
|
39
|
+
COPY --from=tini /usr/bin/tini-static /usr/bin/tini
|
|
40
|
+
# Mount a persistent volume here to keep ASP.NET Core Data Protection keys across container replacements.
|
|
41
|
+
RUN mkdir -p /home/app/.aspnet/DataProtection-Keys && chown -R app:app /home/app/.aspnet
|
|
42
|
+
WORKDIR /app
|
|
43
|
+
COPY --from=build /app ./
|
|
44
|
+
USER $APP_UID
|
|
45
|
+
EXPOSE 8080
|
|
46
|
+
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s --retries=3 \
|
|
47
|
+
CMD ["node", "-e", "fetch('http://127.0.0.1:8080/healthz').then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]
|
|
48
|
+
# tini is PID 1 and runs the app as its child. The kernel ignores a signal that a container's PID 1 has no handler for,
|
|
49
|
+
# so an app that is PID 1 never dies of its own abort(): after a crash it spins (arm64) or exits with another code than
|
|
50
|
+
# 134. tini passes signals on (docker stop), reaps orphans and exits with the app's code; -s keeps it reaping when
|
|
51
|
+
# another process is PID 1, as under docker run --init.
|
|
52
|
+
ENTRYPOINT ["tini", "-s", "--", "dotnet", "__NAME__.dll"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
**/node_modules
|
|
2
|
+
**/.pnpm-store
|
|
3
|
+
__APP_DIR__/bin
|
|
4
|
+
__APP_DIR__/obj
|
|
5
|
+
__APP_DIR__/dist
|
|
6
|
+
**/.vite
|
|
7
|
+
**/test-results
|
|
8
|
+
**/playwright-report
|
|
9
|
+
__APP_DIR__/publish
|
|
10
|
+
__APP_DIR__/tests
|
|
11
|
+
__APP_DIR__/e2e
|
|
12
|
+
**/.git
|
|
13
|
+
**/.env
|
|
14
|
+
**/.env.*
|
|
15
|
+
!**/.env.example
|
package/template/README.md
CHANGED
|
@@ -15,7 +15,7 @@ dotnet publish -c Release
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
- `app/` holds the pages, as in the Next.js App Router: `page.tsx` is `/`, `about/page.tsx` is `/about`, `layout.tsx` wraps them all, `not-found.tsx` and `error.tsx` handle the rest. `app/document.test.ts` renders the home page's whole document, as the server sends it, with `renderDocument` from `netjes/testing`.
|
|
18
|
-
- `
|
|
18
|
+
- `app/icon.svg` is the app's icon, the Netjes mark until you replace it: Netjes serves it at `/icon.svg` and links it from every page. `favicon.ico`, `apple-icon.png` and `manifest.webmanifest` next to it work the same way. Put other static files in `public/` (create it), which is served at the site root.
|
|
19
19
|
- `Features/` holds the C# side, one folder per feature: `Features/Home/HomePage.cs` maps the home page's loader and the `home.greet` server action the form calls.
|
|
20
20
|
- `tests/__NAME__.Tests/` holds the C# tests: `AppFactory.cs` runs the real app in memory, with no Node and no client build, and `HomePageTests.cs` tests the home page's loader and form. `e2e/` holds the Playwright tests, which `playwright.config.ts` runs against the app in Development and in Production. `__NAME__.csproj` leaves these two root folders out of the app's build, so keep the app's own C# out of them.
|
|
21
21
|
- `tsconfig.json` points to two configs: `tsconfig.app.json` checks the app's code without Node's types, `tsconfig.node.json` checks `vite.config.ts`, `playwright.config.ts`, `e2e/` and `scripts/` with them.
|
|
@@ -25,4 +25,8 @@ dotnet publish -c Release
|
|
|
25
25
|
|
|
26
26
|
Outside Development, `Program.cs` sends HSTS on https responses and redirects http to https once the app knows its https port (`ASPNETCORE_HTTPS_PORT` or `ASPNETCORE_HTTPS_PORTS`). Behind a proxy that terminates TLS, add `UseForwardedHeaders()` (trusting only that proxy) so proxied requests count as https and get HSTS, and let the proxy redirect plain http. Netjes adds `X-Content-Type-Options: nosniff` to every response that passes through `UseNetjes()`, static files and API endpoints included, and `Referrer-Policy` and `X-Frame-Options` (`SAMEORIGIN`, or what a Content-Security-Policy's `frame-ancestors` implies) to every document it renders; see `NetjesOptions.SecurityHeaders` to change that.
|
|
27
27
|
|
|
28
|
+
<!--netjes:if pnpm-->
|
|
29
|
+
Develop on the host with `pnpm dev`. __COMPOSE_SETUP__ Run `pnpm install` and commit `pnpm-lock.yaml`. To build the production image, run `__DOCKER_BUILD__` from the __DOCKER_CONTEXT__. The image runs as the non-root app user under tini and checks `/healthz` on port 8080. Mount a persistent volume writable by the `app` user at `/home/app/.aspnet/DataProtection-Keys` to keep ASP.NET Core Data Protection keys across container replacements. When scaffolding from a Netjes checkout for use with Docker, pass `netjes new --packages` so Docker can restore the published packages.
|
|
30
|
+
<!--netjes:else-->
|
|
28
31
|
With Docker: `docker compose up` for development, `docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d` for production. Both publish the app on port 8080 of the host, development on 127.0.0.1 only; set `APP_PORT`, in the shell or a `.env` file, to use another port (`APP_PORT=8090 docker compose up`). Development also publishes Vite on 5173; `VITE_PORT` moves it (`VITE_PORT=5190 docker compose up`). The production image runs the app under tini, which passes the signal of `docker stop` on to the app and ends the container when the app crashes, with exit code 134, so `restart: always` starts it again. In Development `appsettings.Development.json` limits `AllowedHosts` to loopback names (a DNS-rebinding guard); add a name there if you reach the dev app by another host. The Docker build restores Netjes from NuGet and npm, which is how any app made by `npx netjes new` references it. Only an app scaffolded from a Netjes checkout references the checkout instead; scaffold it with `netjes new --packages` to build it in Docker.
|
|
32
|
+
<!--netjes:end-->
|
package/template/_AGENTS.md
CHANGED
|
@@ -24,7 +24,8 @@ How this app is built, for coding agents and the people working with them. It is
|
|
|
24
24
|
<!--netjes:end-->
|
|
25
25
|
| `generated/netjes.ts` | Generated from the C# types and the page files: zod schemas for page and layout props (`pages`, `layouts`), `sharedProps`, typed `serverActions`, `api` schemas for JSON endpoints, `endpointUrl()` for the URLs of the app's endpoints, `route()` and the `Href` type, the pages of mounted page packages included. Never edit it. |
|
|
26
26
|
| `styles/global.css` | Tailwind CSS (`@import 'tailwindcss'`), imported by `app/layout.tsx`. |
|
|
27
|
-
| `
|
|
27
|
+
| `app/icon.svg` | The app's icon (the Netjes mark; replace it). Metadata files at the root of `app/` (`favicon.ico`, `icon.*`, `apple-icon.*`, `manifest.webmanifest`) are served at the site root and linked from every page: no `<link>` tags or `metadata.icons` needed. Only the root counts; the same name in `public/` stops the app. |
|
|
28
|
+
| `public/` | Other static files (create it when you need one), served at the site root. |
|
|
28
29
|
|
|
29
30
|
## Commands
|
|
30
31
|
|
|
@@ -69,9 +70,12 @@ A page without a loader is a plain default export and gets empty props. Forms ca
|
|
|
69
70
|
- Action inputs are records with `init` properties: `public sealed record NoteInput { [Required] public string? Text { get; init; } public bool Pinned { get; init; } }`. A field the post leaves out, such as an unchecked checkbox, keeps its default; form binding refuses (400) a post that lacks one of a positional record's constructor fields. DataAnnotations on them (`[Required]`, `[StringLength]`) are checked before the action runs and come back as field errors, with no setup, also for a post that has none of the input's fields. Return `ServerAction.Invalid(field, message)` for other errors the user can fix.
|
|
70
71
|
- `.CachePage(...)` only for pages that are the same for every visitor: their loaders and shared props must not depend on cookies or other per-visitor state. In the Development environment pages are never output-cached (each request renders them), so check caching on `npx netjes build && npx netjes start`, or in a `WebApplicationFactory` test in the `Testing` environment with `Netjes:Mode` set to `Development`, as the `AppFactory.cs` that `netjes new` writes runs. Each query string as sent is an entry of its own: name the keys a cached page reads with `.CacheQueryKeys("page")`, or `.CacheQueryKeys()` for none, so other query strings render without being stored (`.claude/skills/netjes/references/caching-and-streaming.md`).
|
|
71
72
|
- In the TypeScript configs `netjes new` writes, `tsconfig.app.json` checks the app's code without Node's types, so a component or page that reads `process` or imports `node:*` fails `npm run typecheck`. Code that runs only in Node goes in `scripts/`, which `tsconfig.node.json` checks with them; do not add `node` to the `types` of `tsconfig.app.json`.
|
|
73
|
+
- The viewport is `export const viewport: Viewport = { ... }` in a layout or page (`themeColor`, `viewportFit`, `colorScheme` and the rest); never render a `<meta name="viewport">`, which would be a second one. Write metadata URLs (`alternates.canonical`, `openGraph.images`) relative and set `Netjes:SiteUrl` in configuration: they resolve against it, under the base path.
|
|
72
74
|
- An `error.tsx` renders `error.message` only when `!error.withheld`, and shows `error.status ?? 500` if it shows a status.
|
|
73
75
|
- `Netjes:PublicConfig` is sent to the browser: never put secrets there. So is the route of each endpoint with an `endpointUrl` key, one mapped only in Development included, once any component calls `endpointUrl`: keep secrets out of routes, and authorize on the endpoint ([security](https://github.com/DennisVerhoeven/netjes/blob/main/docs/guides/security.md#errors-and-configuration)).
|
|
74
76
|
- Page packages (pages, layouts, loaders and actions from an npm and NuGet package pair) are mounted, never copied into `app/`: the package's extension in `Program.cs` before `app.MapPages()`, at a prefix in folder syntax (`app.MapHelpCenter("/help")`, `"/(marketing)/help"`), and the npm name in `netjes({ packages })` in `vite.config.ts`. Install both halves at one version. Its files merge into `app/` folder by folder, so an app page in its folder renders inside its layouts. An app page of the same shape as one of its pages stops the app: replace the package's page with `.Override("/help/contact")` on the mount, reading the props from the package's generated file. Conventions on the mount cover only the package's pages; protect the app's own pages under the prefix as usual. For a package that draws its own shell, keep `app/layout.tsx` to providers and the skip link, and put the site's chrome in `app/(site)/layout.tsx`. Run `npx netjes generate` after updating a package ([page packages](https://github.com/DennisVerhoeven/netjes/blob/main/docs/guides/page-packages.md)).
|
|
77
|
+
- Pages that must open without a network opt in with `.AvailableOffline()` and a service worker built with `netjes({ serviceWorker: 'sw.ts' })` (`netjes/service-worker`); read the offline guide in the Netjes docs before using it, since stored pages can hold personal data. A manifest, icons and `viewport` make the app installable.
|
|
78
|
+
- If the app uses pnpm: `pnpm dev` runs on the host, and the image is built with `docker build .` (from the workspace root with `-f <app>/Dockerfile` for an app in a pnpm workspace).
|
|
75
79
|
- Write the failing test first, then the change.
|
|
76
80
|
|
|
77
81
|
## Before you finish
|
package/template/app/layout.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import '../styles/global.css';
|
|
|
4
4
|
|
|
5
5
|
export const metadata: Metadata = {
|
|
6
6
|
title: { default: '__TITLE__', template: '%s · __TITLE__' },
|
|
7
|
-
icons: { icon: '/favicon.svg' },
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
const navLink = 'text-slate-500 no-underline hover:text-slate-900 aria-[current=page]:text-slate-900';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
// The flags of create-vite's React-TS template plus stricter checks on top of `strict`.
|
|
3
|
+
// Each project extending this base supplies its own include and may override the ambient types.
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2023",
|
|
6
|
+
"lib": ["ES2023", "DOM"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"moduleDetection": "force",
|
|
10
|
+
"types": ["vite/client", "node"],
|
|
11
|
+
"jsx": "react-jsx",
|
|
12
|
+
"strict": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"allowImportingTsExtensions": true,
|
|
15
|
+
"allowArbitraryExtensions": true,
|
|
16
|
+
"verbatimModuleSyntax": true,
|
|
17
|
+
"noEmit": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"erasableSyntaxOnly": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"noUncheckedSideEffectImports": true,
|
|
23
|
+
"noUncheckedIndexedAccess": true,
|
|
24
|
+
"noImplicitOverride": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true
|
|
26
|
+
}
|
|
27
|
+
}
|
package/vite/packages.mjs
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// The Vite plugin, the development sidecar (through the plugin's api) and the CLI read them from here.
|
|
4
4
|
import { readFileSync, realpathSync, statSync } from 'node:fs';
|
|
5
5
|
import { readdir } from 'node:fs/promises';
|
|
6
|
+
import { createRequire, registerHooks } from 'node:module';
|
|
6
7
|
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
9
|
import { satisfies } from '../cli/info.mjs';
|
|
8
10
|
import { findPackage } from '../cli/packages.mjs';
|
|
9
11
|
|
|
@@ -74,6 +76,101 @@ function isFile(file) {
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
/** @param {string} file @param {string} specifier @param {'require' | 'import'} mode */
|
|
80
|
+
function resolveConfigExport(file, specifier, mode) {
|
|
81
|
+
const parent = pathToFileURL(file);
|
|
82
|
+
// Node can cache by parent URL and specifier, so give each set of conditions its own parent URL.
|
|
83
|
+
parent.searchParams.set('netjes-tsconfig', mode);
|
|
84
|
+
const conditions = ['node', 'types', mode];
|
|
85
|
+
const hooks = registerHooks({
|
|
86
|
+
resolve: (name, context, nextResolve) => nextResolve(name, { ...context, parentURL: parent.href, conditions }),
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
const target = fileURLToPath(import.meta.resolve(specifier));
|
|
90
|
+
if (path.extname(target) === '.json' && isFile(target)) return target;
|
|
91
|
+
} catch {
|
|
92
|
+
// The caller tries the next config filename or mode.
|
|
93
|
+
} finally {
|
|
94
|
+
hooks.deregister();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** @param {string} file @param {string} specifier */
|
|
99
|
+
function resolveExtendedConfig(file, specifier) {
|
|
100
|
+
const dir = path.dirname(file);
|
|
101
|
+
if (/^\.{1,2}[/\\]/.test(specifier) || path.isAbsolute(specifier)) {
|
|
102
|
+
const target = path.resolve(dir, specifier);
|
|
103
|
+
return [target, `${target}.json`].find(isFile);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Bare config packages may name their base with the tsconfig field. Subpath exports resolve from the package
|
|
107
|
+
// that owns this config, including when a base lives in a different workspace package.
|
|
108
|
+
const manifest = isPackageName(specifier) ? findPackage(dir, specifier) : null;
|
|
109
|
+
if (manifest) {
|
|
110
|
+
const { tsconfig } = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
111
|
+
if (typeof tsconfig === 'string') {
|
|
112
|
+
const target = path.resolve(path.dirname(manifest), tsconfig);
|
|
113
|
+
if (isFile(target)) return target;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const requireFromConfig = createRequire(file);
|
|
117
|
+
for (const name of [specifier, `${specifier}.json`, `${specifier}/tsconfig.json`]) {
|
|
118
|
+
// TypeScript looks up base configs with `require` and `types`. Also accept import entries for Vite.
|
|
119
|
+
const exported = resolveConfigExport(file, name, 'require') ?? resolveConfigExport(file, name, 'import');
|
|
120
|
+
if (exported) return exported;
|
|
121
|
+
try {
|
|
122
|
+
const target = requireFromConfig.resolve(name);
|
|
123
|
+
if (path.extname(target) === '.json') return target;
|
|
124
|
+
} catch {
|
|
125
|
+
// Try the next TypeScript config filename.
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Checks a linked page package's config before Vite transforms its pages. @param {PagePackage} pkg */
|
|
132
|
+
export function checkPackageTsconfig(pkg) {
|
|
133
|
+
const rootConfig = path.join(pkg.root, 'tsconfig.json');
|
|
134
|
+
if (!isFile(rootConfig)) return;
|
|
135
|
+
/** @type {Set<string>} */
|
|
136
|
+
const visited = new Set();
|
|
137
|
+
|
|
138
|
+
/** @param {string} config */
|
|
139
|
+
function check(config) {
|
|
140
|
+
const file = realpathSync(config);
|
|
141
|
+
if (visited.has(file)) return;
|
|
142
|
+
visited.add(file);
|
|
143
|
+
|
|
144
|
+
// TypeScript accepts comments and trailing commas. Keep quoted values intact, including comment-like text.
|
|
145
|
+
const strings = /"(?:[^"\\]|\\.)*"/;
|
|
146
|
+
const text = readFileSync(file, 'utf8')
|
|
147
|
+
.replace(/^\uFEFF/, '')
|
|
148
|
+
.replace(new RegExp(`${strings.source}|//[^\\r\\n]*|/\\*[\\s\\S]*?\\*/`, 'g'), (token) => token.startsWith('"') ? token : ' ')
|
|
149
|
+
.replace(new RegExp(`${strings.source}|,(?=\\s*[}\\]])`, 'g'), (token) => token === ',' ? '' : token);
|
|
150
|
+
let bases;
|
|
151
|
+
try {
|
|
152
|
+
const parsed = JSON.parse(text);
|
|
153
|
+
bases = Array.isArray(parsed?.extends) ? parsed.extends : [parsed?.extends];
|
|
154
|
+
} catch {
|
|
155
|
+
// Vite supplies its own syntax diagnostics. This check adds context to missing bases.
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
for (const base of bases) {
|
|
159
|
+
if (typeof base !== 'string') continue;
|
|
160
|
+
const target = resolveExtendedConfig(file, base);
|
|
161
|
+
if (!target) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`netjes: ${pkg.name}: ${file} extends ${JSON.stringify(base)}, which does not resolve. ` +
|
|
164
|
+
`Add the shared config as a devDependency of ${pkg.name} or extend an installed config by its package name.`,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
check(target);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
check(rootConfig);
|
|
172
|
+
}
|
|
173
|
+
|
|
77
174
|
/**
|
|
78
175
|
* Reads and checks the page packages the app lists, in the order it lists them. Each error is one line that names the
|
|
79
176
|
* package and what to do.
|
package/vite/plugin.d.ts
CHANGED
|
@@ -4,13 +4,20 @@ import type { PluginOption } from 'vite';
|
|
|
4
4
|
|
|
5
5
|
/** Options for the `netjes()` Vite plugin. */
|
|
6
6
|
export type NetjesPluginOptions = {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The directory of page files (Next.js App Router conventions), relative to the Vite root. Must match
|
|
9
|
+
* Netjes:AppDirectory. Default `app`. The client build copies the metadata files at its root (`favicon.ico`,
|
|
10
|
+
* `icon*`, `apple-icon*`, `manifest.webmanifest` or `manifest.json`) into `dist/client` and lists them in
|
|
11
|
+
* `dist/client/.vite/metadata-files.json`, which the .NET app links; a file of the same name in `public/` fails the build.
|
|
12
|
+
*/
|
|
8
13
|
appDir?: string;
|
|
9
14
|
/**
|
|
10
15
|
* Like Next.js's `basePath`: the path the app is mounted under with `app.UsePathBase(...)`, e.g. `/docs`.
|
|
11
16
|
* Built asset URLs get it; links, forms, redirects and router calls get it from the server at runtime.
|
|
12
17
|
*/
|
|
13
18
|
basePath?: string;
|
|
19
|
+
/** Service worker entry relative to the Vite root. The client build writes it as a classic script at `dist/client/sw.js`. */
|
|
20
|
+
serviceWorker?: string;
|
|
14
21
|
/**
|
|
15
22
|
* Page packages, by npm name: installed packages whose `package.json` has a `netjes` field, and which the .NET app
|
|
16
23
|
* mounts at a prefix. Their convention files join the page module map and both builds, their sources and stylesheet
|
package/vite/plugin.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
4
|
+
import { copyFile, mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { createRequire, registerHooks } from 'node:module';
|
|
5
6
|
import path from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
8
|
import react from '@vitejs/plugin-react';
|
|
8
|
-
import { normalizePath, searchForWorkspaceRoot } from 'vite';
|
|
9
|
+
import { build, normalizePath, searchForWorkspaceRoot } from 'vite';
|
|
9
10
|
import { findPackage } from '../cli/packages.mjs';
|
|
10
11
|
import {
|
|
11
12
|
CONVENTION_EXTENSIONS,
|
|
12
13
|
CONVENTION_FILES,
|
|
14
|
+
checkPackageTsconfig,
|
|
13
15
|
commonJsDependencies,
|
|
14
16
|
fileId,
|
|
15
17
|
filePath,
|
|
@@ -46,6 +48,40 @@ const RESOLVED_QUERY_ID = `\0${QUERY_ID}`;
|
|
|
46
48
|
*/
|
|
47
49
|
const isTailwindStylesheet = (id) =>
|
|
48
50
|
!/[?&](?:worker|sharedworker|raw|url)\b|\?commonjs-proxy/.test(id) && !id.includes('/.vite/') && (id.split('?')[0] ?? id).endsWith('.css');
|
|
51
|
+
/**
|
|
52
|
+
* A metadata file's name at the root of the app directory (MetadataFiles.cs has the same rule): favicon.ico, icon and
|
|
53
|
+
* icon1, icon2, ... in .ico, .png, .svg, .jpg or .jpeg, apple-icon and on in .png, .jpg or .jpeg, and the web app
|
|
54
|
+
* manifest. Lower case only.
|
|
55
|
+
*/
|
|
56
|
+
const METADATA_FILE = /^(?:favicon\.ico|icon[0-9]*\.(?:ico|png|svg|jpg|jpeg)|apple-icon[0-9]*\.(?:png|jpg|jpeg)|manifest\.(?:webmanifest|json))$/;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The metadata files at the root of a folder, in ordinal order: files, and links to files, as the .NET app reads them
|
|
60
|
+
* in development.
|
|
61
|
+
* @param {string} dir
|
|
62
|
+
* @returns {Promise<string[]>}
|
|
63
|
+
*/
|
|
64
|
+
async function metadataFiles(dir) {
|
|
65
|
+
/** @type {import('node:fs').Dirent[]} */
|
|
66
|
+
let entries;
|
|
67
|
+
try {
|
|
68
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
69
|
+
} catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const found = await Promise.all(
|
|
73
|
+
entries
|
|
74
|
+
.filter((entry) => METADATA_FILE.test(entry.name))
|
|
75
|
+
.map(async (entry) => {
|
|
76
|
+
if (entry.isFile()) return entry.name;
|
|
77
|
+
if (!entry.isSymbolicLink()) return null;
|
|
78
|
+
const target = await stat(path.join(dir, entry.name)).catch(() => null);
|
|
79
|
+
return target?.isFile() ? entry.name : null;
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
return found.filter((name) => name !== null).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
83
|
+
}
|
|
84
|
+
|
|
49
85
|
/** The URL the .NET dev asset resolver points browsers at. */
|
|
50
86
|
const DEV_CLIENT_ENTRY_URL = '/@netjes/client-entry';
|
|
51
87
|
|
|
@@ -82,10 +118,27 @@ function backendDirs(dir) {
|
|
|
82
118
|
*/
|
|
83
119
|
const literalGlob = (file) => file.replace(/[()[\]{}*?|]|[!+@](?=\()/g, '\\$&');
|
|
84
120
|
|
|
85
|
-
/**
|
|
86
|
-
async function
|
|
121
|
+
/** @param {string} root */
|
|
122
|
+
async function loadTailwind(root) {
|
|
87
123
|
try {
|
|
88
|
-
|
|
124
|
+
let entry;
|
|
125
|
+
const parentURL = pathToFileURL(path.join(root, 'package.json')).href;
|
|
126
|
+
// Use Node's import conditions with the app as the parent, without a startup flag for import.meta.resolve.
|
|
127
|
+
const hooks = registerHooks({
|
|
128
|
+
resolve: (specifier, context, nextResolve) => nextResolve(specifier, { ...context, parentURL }),
|
|
129
|
+
});
|
|
130
|
+
try {
|
|
131
|
+
entry = import.meta.resolve('@tailwindcss/vite');
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ERR_MODULE_NOT_FOUND')) throw error;
|
|
134
|
+
} finally {
|
|
135
|
+
hooks.deregister();
|
|
136
|
+
}
|
|
137
|
+
// import.meta.resolve can return a URL even when the export's target file is missing.
|
|
138
|
+
/** @type {typeof import('@tailwindcss/vite')} */
|
|
139
|
+
const { default: plugin } = entry && statSync(new URL(entry), { throwIfNoEntry: false })?.isFile()
|
|
140
|
+
? await import(entry)
|
|
141
|
+
: await import('@tailwindcss/vite');
|
|
89
142
|
return plugin();
|
|
90
143
|
} catch (error) {
|
|
91
144
|
throw new Error(
|
|
@@ -96,6 +149,42 @@ async function tailwind() {
|
|
|
96
149
|
}
|
|
97
150
|
}
|
|
98
151
|
|
|
152
|
+
/** Loads Tailwind once Vite has the app's root and shares its state across the app's environments. @returns {import('vite').Plugin} */
|
|
153
|
+
function tailwindForApp() {
|
|
154
|
+
/** @type {WeakMap<import('vite').ResolvedConfig, { plugins: import('vite').Plugin[], serverHooks: import('vite').ServerHook[] }>} */
|
|
155
|
+
const tailwind = new WeakMap();
|
|
156
|
+
return {
|
|
157
|
+
name: 'netjes:tailwind',
|
|
158
|
+
enforce: 'pre',
|
|
159
|
+
async configResolved(config) {
|
|
160
|
+
/** @type {import('vite').Plugin[]} */
|
|
161
|
+
const plugins = [];
|
|
162
|
+
/** @type {import('vite').ServerHook[]} */
|
|
163
|
+
const serverHooks = [];
|
|
164
|
+
// Tailwind's Vite-wide hooks run here and in configureServer. Vite runs the remaining hooks per environment.
|
|
165
|
+
for (const { apply, configResolved, configureServer, ...plugin } of await loadTailwind(config.root)) {
|
|
166
|
+
if (typeof apply === 'string' && apply !== config.command) continue;
|
|
167
|
+
const resolved = typeof configResolved === 'function' ? configResolved : configResolved?.handler;
|
|
168
|
+
await resolved?.call(this, config);
|
|
169
|
+
const server = typeof configureServer === 'function' ? configureServer : configureServer?.handler;
|
|
170
|
+
if (server) serverHooks.push(server);
|
|
171
|
+
plugins.push(plugin);
|
|
172
|
+
}
|
|
173
|
+
tailwind.set(config, { plugins, serverHooks });
|
|
174
|
+
},
|
|
175
|
+
async configureServer(server) {
|
|
176
|
+
/** @type {Array<() => void>} */
|
|
177
|
+
const postHooks = [];
|
|
178
|
+
for (const hook of tailwind.get(server.config)?.serverHooks ?? []) {
|
|
179
|
+
const post = await hook.call(this, server);
|
|
180
|
+
if (post) postHooks.push(post);
|
|
181
|
+
}
|
|
182
|
+
return () => postHooks.forEach((hook) => hook());
|
|
183
|
+
},
|
|
184
|
+
applyToEnvironment: (environment) => tailwind.get(environment.getTopLevelConfig())?.plugins ?? [],
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
99
188
|
/**
|
|
100
189
|
* Whether the app (or a parent workspace) can import a package.
|
|
101
190
|
* @param {string} root
|
|
@@ -214,6 +303,10 @@ export default function netjes(options = {}) {
|
|
|
214
303
|
let rootDir = '';
|
|
215
304
|
/** @type {string} */
|
|
216
305
|
let outDir = '';
|
|
306
|
+
/** Vite's public directory, or '' when it has none. @type {string} */
|
|
307
|
+
let publicDir = '';
|
|
308
|
+
/** @type {import('vite').ResolvedConfig} */
|
|
309
|
+
let resolvedConfig;
|
|
217
310
|
/** @type {import('vite').ViteDevServer | undefined} */
|
|
218
311
|
let devServer;
|
|
219
312
|
/** The page packages the app lists, read when the config is. @type {import('./packages.mjs').PagePackage[]} */
|
|
@@ -282,6 +375,7 @@ export default function netjes(options = {}) {
|
|
|
282
375
|
...test,
|
|
283
376
|
...base,
|
|
284
377
|
appType: 'custom',
|
|
378
|
+
define: { __NETJES_DEV__: JSON.stringify(env.command === 'serve') },
|
|
285
379
|
// One copy of each, even when netjes is linked (a `file:` dependency, npm link) and has its own node_modules.
|
|
286
380
|
resolve: {
|
|
287
381
|
dedupe: [
|
|
@@ -351,12 +445,17 @@ export default function netjes(options = {}) {
|
|
|
351
445
|
};
|
|
352
446
|
},
|
|
353
447
|
configResolved(config) {
|
|
448
|
+
resolvedConfig = config;
|
|
354
449
|
rootDir = config.root;
|
|
355
450
|
outDir = path.resolve(config.root, config.build.outDir);
|
|
451
|
+
publicDir = config.publicDir || '';
|
|
356
452
|
},
|
|
357
453
|
// The app's route table stops it on a route handler in development, and in every command that starts it. A build
|
|
358
454
|
// takes only the convention files, so it would leave one out without a word: it stops on it too, saying the same.
|
|
359
455
|
async buildStart() {
|
|
456
|
+
for (const pkg of packages) {
|
|
457
|
+
if (pkg.linked) checkPackageTsconfig(pkg);
|
|
458
|
+
}
|
|
360
459
|
if (!isBuild) return;
|
|
361
460
|
let handler = await findRouteHandler(rootDir, appDir);
|
|
362
461
|
// A package's, by its file id, as the route table names it.
|
|
@@ -368,6 +467,16 @@ export default function netjes(options = {}) {
|
|
|
368
467
|
if (handler) {
|
|
369
468
|
this.error(`'${handler}': route handlers are C# in Netjes. Map a minimal API endpoint instead (app.MapGet, app.MapPost, ...).`);
|
|
370
469
|
}
|
|
470
|
+
// The client build copies public/ and the metadata files into one folder: the same name in both would be one file.
|
|
471
|
+
if (isSsrBuild || !publicDir) return;
|
|
472
|
+
for (const name of await metadataFiles(path.join(rootDir, appDir))) {
|
|
473
|
+
if (!existsSync(path.join(publicDir, name))) continue;
|
|
474
|
+
const where = (/** @type {string} */ dir) => normalizePath(path.relative(rootDir, path.join(dir, name)));
|
|
475
|
+
this.error(
|
|
476
|
+
`netjes: ${where(publicDir)} and ${where(path.join(rootDir, appDir))} are both served at /${name}. ` +
|
|
477
|
+
`Keep one: the file in ${appDir}/ is linked from every page, the one in public/ only served.`,
|
|
478
|
+
);
|
|
479
|
+
}
|
|
371
480
|
},
|
|
372
481
|
configureServer(server) {
|
|
373
482
|
devServer = server;
|
|
@@ -440,6 +549,44 @@ export default function netjes(options = {}) {
|
|
|
440
549
|
await copyFile(SIDECAR, path.join(outDir, 'netjes-sidecar.mjs'));
|
|
441
550
|
return;
|
|
442
551
|
}
|
|
552
|
+
// The metadata files at the root of the app directory, served at the site root from the client build, and the
|
|
553
|
+
// list of them the .NET app links: not every file in dist/client, which also holds what Vite copied from public/.
|
|
554
|
+
const metadata = await metadataFiles(path.join(rootDir, appDir));
|
|
555
|
+
if (metadata.length > 0) {
|
|
556
|
+
await Promise.all(metadata.map((name) => copyFile(path.join(rootDir, appDir, name), path.join(outDir, name))));
|
|
557
|
+
await mkdir(path.join(outDir, '.vite'), { recursive: true });
|
|
558
|
+
await writeFile(path.join(outDir, '.vite', 'metadata-files.json'), `${JSON.stringify({ files: metadata }, null, 2)}\n`);
|
|
559
|
+
}
|
|
560
|
+
// netjes export requests each page under it, so app.UsePathBase sees the base path the assets were built for.
|
|
561
|
+
if (basePath) {
|
|
562
|
+
await mkdir(path.join(outDir, '.vite'), { recursive: true });
|
|
563
|
+
await writeFile(path.join(outDir, '.vite', 'base-path.json'), `${JSON.stringify({ basePath }, null, 2)}\n`);
|
|
564
|
+
}
|
|
565
|
+
if (options.serviceWorker) {
|
|
566
|
+
const manifest = await readFile(path.join(outDir, '.vite', 'manifest.json'));
|
|
567
|
+
// Match the version the .NET app derives from the same manifest.
|
|
568
|
+
const version = createHash('sha256').update(manifest).digest('hex').slice(0, 12);
|
|
569
|
+
await build({
|
|
570
|
+
root: rootDir,
|
|
571
|
+
configFile: false,
|
|
572
|
+
mode: resolvedConfig.mode,
|
|
573
|
+
base: resolvedConfig.base,
|
|
574
|
+
logLevel: resolvedConfig.logLevel,
|
|
575
|
+
resolve: { alias: resolvedConfig.resolve.alias },
|
|
576
|
+
define: { __NETJES_BUILD__: JSON.stringify(version) },
|
|
577
|
+
build: {
|
|
578
|
+
outDir,
|
|
579
|
+
emptyOutDir: false,
|
|
580
|
+
copyPublicDir: false,
|
|
581
|
+
lib: {
|
|
582
|
+
entry: path.resolve(rootDir, options.serviceWorker),
|
|
583
|
+
formats: ['iife'],
|
|
584
|
+
name: 'NetjesServiceWorker',
|
|
585
|
+
fileName: () => 'sw.js',
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
}
|
|
443
590
|
if (packages.length === 0) return;
|
|
444
591
|
// Where the .NET app finds the packages in production, next to the manifest: no node_modules there to read them
|
|
445
592
|
// from, and a manifest key alone does not say which package a file is of.
|
|
@@ -477,5 +624,5 @@ export default function netjes(options = {}) {
|
|
|
477
624
|
},
|
|
478
625
|
};
|
|
479
626
|
|
|
480
|
-
return [react(options.react), plugin, packageNames.length > 0 ? packageStyles : null, options.tailwind === false ? null :
|
|
627
|
+
return [react(options.react), plugin, packageNames.length > 0 ? packageStyles : null, options.tailwind === false ? null : tailwindForApp()];
|
|
481
628
|
}
|
|
File without changes
|