Files
sweet/packages/plugin-vite
Brett Chalupa de1810e70d fix(vite): exclude test files from production builds (#3559)
The Vite plugin was not filtering out test files from route discovery,
causing test files in routes/ (e.g., routes/api/counter_test.ts) to be
bundled into production builds, inflating bundle sizes by ~20KB per test
file and including unnecessary test dependencies.

Root cause: Vite plugin defaulted ignore patterns to [] while Builder
correctly defaults to [TEST_FILE_PATTERN].

This fix:

- Defines TEST_FILE_PATTERN in shared constants.ts for reusability
- Exports TEST_FILE_PATTERN from internals_dev.ts for Vite plugin access
- Updates Vite plugin default from [] to [TEST_FILE_PATTERN]
- Updates Builder to import TEST_FILE_PATTERN from constants.ts
- Ensures test files matching /[._]test\.(?:[tj]sx?|[mc][tj]s)$/ are
excluded
- Adds integration test to prevent regression
- Allows Deno best practice of colocating test files without bundling
them

Test coverage (prevents regression):

- Unit test: walkDir respects skip patterns
- Unit test: crawlRouteDir excludes test files
- Integration test: Vite builds exclude test files from output

Fixes #3558
2025-10-21 11:26:20 +02:00
..
2025-10-08 12:56:08 +02:00
2025-09-02 17:41:17 +02:00

Fresh vite plugin

Vite plugin for Fresh.

Usage

  1. Run deno install jsr:@fresh/plugin-vite npm:vite
  2. Ensure that your deno.json has the fresh import mapping:
{
  "imports": {
    "fresh": "jsr:@fresh/core"
  }
}
  1. Update your vite.config.ts file:
  import { defineConfig } from "vite";
+ import { fresh } from "@fresh/plugin-vite";
  
  export default defineConfig({
    plugins: [
+     fresh(),
    ],
  });
  1. Update your deno tasks respectively:
  • Dev: vite
  • Build: vite build

More information on the Fresh documentation .