@wtf/project-vite
Documentation / @wtf/project-vite
The base Vite config that every Vite config in a workspace starts from: an app’s vite.config, a
Storybook’s viteFinal, and each config of @wtf/project-vitest,
which starts from it by itself.
| Subpath | What you get |
|---|---|
./config | baseConfig, the base config; compress, the plugin that writes brotli and gzip copies in a site’s build; conditionsOf, buildsSite, CLIENT_CONDITIONS, COMPRESSIBLE, THRESHOLD, FROM_DIST |
import { defineConfig, mergeConfig } from 'vite'
import { baseConfig } from '@wtf/project-vite/config'
export default defineConfig(mergeConfig(baseConfig(), { server: { port: 5173 } }))The base has two layers:
- For every command: the workspace’s packages resolve to their TypeScript through their
@wtf/sourcecondition (SOURCE_CONDITIONof@wtf/project-resolve/condition), with no build first; or, withTEST_FROM=dist, to their build. - For a site’s
vite buildonly: a brotli and a gzip copy next to each text file it writes, made by vite-plugin-compression2. A static host such as GitLab Pages serves the copy instead to a browser that accepts it. It never applies to a dev server, a test, a library build (build.lib) or a server build (build.ssr).baseConfig({ compress: false })writes no copies.
It owns the workspace’s Vite: it depends on vite at ^8.3.5, and on vite-plugin-compression2,
the one library for the copies. The config imports only Vite’s types. A repo names vite only in
a manifest whose own code imports it, with the same range, and never names rolldown. The
Vite guide has the rest.
The base Vite config of a workspace: baseConfig(), which each Vite config starts from, by Vite’s
mergeConfig, an app’s vite.config, a Storybook’s viteFinal, and each config of
@wtf/project-vitest, so a dev server, a test and a build resolve as one.
It holds two layers:
- The base, of every command: the workspace’s packages resolved by their
@wtf/sourcecondition, the TypeScript of the workspace, with no build first; or, withTEST_FROM=dist, as a consumer resolves them, by their build (conditionsOf). - The site, of
vite buildalone: a brotli and a gzip copy beside each file of text the build writes,<file>.brand<file>.gz, by vite-plugin-compression2, which a static host, as GitLab Pages, serves in its place to a browser that takes it (compress). Never of a dev server or a test, which serve, nor of a library’s build (build.lib) or a server’s (build.ssr), whose files a package publishes or a server runs, and no browser fetches.
// vite.config.ts of an appimport { defineConfig, mergeConfig } from 'vite'
import { baseConfig } from '@wtf/project-vite/config'
export default defineConfig(mergeConfig(baseConfig(), { server: { port: 5173 } }))