Drn buildwww vite

From duranserkan/DRN-Project · View interactive version

Drn buildwww vite is an AI agent skill from the GitHub repository duranserkan/DRN-Project. DRN Vite runtime and domain builds. Keywords: drn, buildwww, vite, typescript, bundles, manifest, cache

How to use this skill

Skill file

DRN buildwww & Vite

Frontend build system using Vite and TypeScript for repositories that declare the DRN buildwww convention.

When to Apply

Directory Structure

Resolve the frontend package root through the profile. Source lives under buildwww/ and served output under wwwroot/.

| Source | Purpose |

|---|---|

| buildwww/app/ts/, buildwww/app/css/ | Application modules and styles |

| buildwww/lib/ | htmx, Bootstrap, and React adapters |

| buildwww/types/ | Shared contracts and ambient declarations |

| vite.config.ts, vite.config.plugin.ts | Targets and plugins |

| tsconfig.json | TypeScript scope and aliases |

| package.json, package-lock.json | Commands and dependencies |


Vite Configuration

Follow Package Imports when choosing dependency paths. Verify stylesheet resolution before migrating existing Sass imports.

Stylesheet conventions

Multi-Build Setup

The frontend root's vite.config.ts defines each target's entry points, plugins, and output directory. Targeted npm scripts set BUILD_TYPE. The default target is app.

For classic-script builds with mixed or multiple entries, use iifeWrap() to isolate each JavaScript chunk and prevent name collisions between bundles. A single named JavaScript entry such as React can use native IIFE output. Keep stripHtmxEval() on the HTMX target to remove its direct eval call from the shipped bundle.

See React integration for Shadow DOM, Tailwind, and island usage.

Build Commands

Builds require explicit permission. Apply the AGENTS.md npm command gate to linting, formatting, type checking, and builds invoked through npm.

The full build runs check for formatting, script and stylesheet linting, type checking, and the advisory Knip report. Targeted builds skip this gate. The package manifest owns commands and lint scope.

Select the full or targeted build:* script from package.json. The profile-declared application guide owns exact commands and setup requirements.

Shared Configuration

Full and targeted builds record a Base64 SHA-256 hash of decoded bytes for each manifest entry. They emit a Brotli quality 11 variant when smaller. List only verified Razor-managed entries for original removal. Bundled references retain the original. Deploy all emitted assets with the hidden manifests. A brotliOnly entry requires its .br file.

Align aliases with tsconfig.json and buildwww. @/* maps to buildwww/* through TypeScript paths. Vite needs a matching resolve.alias for runtime imports. Otherwise keep @/ imports type-only.


TypeScript Configuration

tsconfig.json owns compiler options, source scope, declarations, and aliases. Include the root Vite config and plugin TypeScript files. Align resolution and aliases with Vite. Do not duplicate compiler configuration. Type checking, like builds, requires execution authorization.

Follow imports and types and test conventions.


Package Configuration

Package guidance:


Entry Points

Current builds are app, appPostload, htmx, bootstrap, react, layoutBehaviors, homeBehaviors, and testBehaviors.

Domain Behavior Entries

Keep modules under buildwww/app/ts/behaviors/{layout,home,test}/. Each entry imports only its domain modules and calls existing window.DRN/Bootstrap APIs rather than importing runtime implementations. Read configuration from encoded element data and keep mount state/cleanup local.

| Entry | Output directory | Loading |

|---|---|---|

| layoutBehaviors.ts | wwwroot/behaviors/layout | Global shell after runtime bundles |

| homeBehaviors.ts | wwwroot/behaviors/home | HomeAnonymous page Scripts |

| testBehaviors.ts | wwwroot/behaviors/test | HTMX test page Scripts |

build:behaviors runs build:behaviors:layout, build:behaviors:home, and build:behaviors:test sequentially. Each script explicitly sets BUILD_TYPE to select its Vite target, writes a hashed entry and .vite/manifest.json, and cleans its own directory. The full build calls this aggregate. Unchanged inputs/tooling preserve unrelated bundle cache identities. Keep separate chunks and output roots.

Each entry polls after its imports' deferred registrations on initial load:

if (document.readyState === 'loading')
    document.addEventListener('DOMContentLoaded', () => window.onmount(), {once: true});

Use a fresh callback so listener deduplication cannot reuse an earlier poll from postload. Late script execution registers/polls through DRN.Onmount. Existing htmx polling handles swaps. Registration must tolerate repeated script execution. Runtime bundles, including React, stay global.

Deploy changed assets and hidden manifests together. Restart the app to refresh manifest/SRI caches. Fully reload existing pages for changed registrations. Retain old hashed assets for in-flight pages. The application guide owns migration and deployment details. Intentional inline nonce test fixtures remain in Razor.

appPreload.ts

Loaded early, before page content:

appPostload.ts

Loaded in the global shell's head. Installs application-wide event handlers and defers DOM-dependent work. Component registrations belong to their behavior domains.


Output Structure

Each target emits hashed assets and .vite/manifest.json in its output root. Under wwwroot/, runtime roots are app/, appPostload/, and lib/{htmx,bootstrap,react}/. Behavior roots are listed under Entry Points. Resolve filenames from manifests rather than copying hashes.


Using Built Assets in Razor

<script src="buildwww/app/ts/appPreload.ts"></script>
<link href="buildwww/app/css/app.css" rel="stylesheet" />
<link href="buildwww/lib/bootstrap/bootstrap.scss" rel="stylesheet" />
<script src="buildwww/lib/htmx/htmxBundle.ts"></script>
<script src="buildwww/lib/bootstrap/bootstrapBundle.ts"></script>
<script src="buildwww/app/ts/appPostload.ts"></script>
<script src="buildwww/lib/react/reactBundle.tsx"></script>
<script src="buildwww/app/ts/layoutBehaviors.ts"></script>

TagHelpers resolve these source paths through the per-output .vite/manifest.json files and emit content-hashed wwwroot paths with SRI where applicable.

Home/test entries belong in their owning page's Scripts section, not the global shell. Both full and htmx layout paths must render the section. Preserve normal script tag helper processing, response nonces, SRI, and dependency order. External scripts can finish after htmx's load event, so mount registration must also work when the page is already interactive.

The emitted script and link URLs include Request.PathBase, including manifest-backed preload links. Use a shared relative base: './' so generated CSS asset references and Vite-managed imports/preloads resolve relative to their output files under any proxy prefix. Keep manually authored application assets application-relative with @Url.Content("~/images/favicon.ico"). Non-Vite URLs pass through the Vite helpers unchanged.

DRN Hosting discovers .vite/manifest.json below the active web root, or ContentRootPath/wwwroot when the web root is empty. Preserve manifest visibility when changing environment defaults or publishing. Server startup alone does not prove that rendered pages can load CSS and JavaScript.


Related Skills


Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.