@theholocron/vite-config
v8.2.0
Published
Vite configuration presets for libraries, React apps, and Node tools within the Galaxy.
Maintainers
Readme
Vite Config
A Vite configuration with presets for libraries, React apps, and Node.js tools within the Galaxy.
Installation
pnpm add -D @theholocron/vite-configUsage
Pick the preset that matches your project type. All presets accept an overrides object that is deep-merged last via mergeConfig.
React component library
Outputs ESM + CJS; externalises react and react-dom; wires up @vitejs/plugin-react; sets @ as an alias for src/. Returns a Promise because plugins are loaded dynamically.
import { reactLibrary } from "@theholocron/vite-config/react-library";
export default reactLibrary({ name: "my-lib" });Pass overrides to add project-specific config:
import { reactLibrary } from "@theholocron/vite-config/react-library";
import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
export default reactLibrary({
name: "my-lib",
overrides: {
plugins: [storybookTest()],
},
});Publishable library (non-React)
Outputs ESM only; externalises react and react-dom by default. Returns a Promise because the plugin is loaded dynamically.
import { library } from "@theholocron/vite-config/library";
export default library({ entry: "src/index.ts", name: "MyLib" });React single-page application
Requires @vitejs/plugin-react as a peer dependency. Returns a Promise because the plugin is loaded dynamically.
import { reactApp } from "@theholocron/vite-config/react-app";
export default reactApp();Pass vite-tsconfig-paths via overrides.plugins to enable tsconfig path aliases:
import tsconfigPaths from "vite-tsconfig-paths";
import { reactApp } from "@theholocron/vite-config/react-app";
export default reactApp({ plugins: [tsconfigPaths()] });Node.js CLI tool or server app
Targets Node 22; outputs a single ESM bundle with no browser polyfills. Returns a Promise because the plugin is loaded dynamically.
import { nodeApp } from "@theholocron/vite-config/node-app";
export default nodeApp({ entry: "src/index.ts" });Codecov bundle analysis
All presets automatically include @codecov/vite-plugin when @codecov/vite-plugin is installed and CODECOV_TOKEN is set in the environment. No extra configuration in vite.config.ts is needed — bundle stats are uploaded to Codecov on every build.
Install the peer dependency:
pnpm add -D @codecov/vite-pluginSet CODECOV_TOKEN as a CI secret, then add the following to your codecov.yml to control when Codecov posts bundle size comments on PRs:
comment:
require_bundle_changes: true
bundle_change_threshold: "1Kb"This posts a comment only when bundle size changes by more than 1 KB — enough to flag meaningful regressions without noise from routine fluctuations. See the Codecov bundle analysis docs for more threshold options.
