feat: initial dev-configs monorepo

Shared configs for TypeScript projects: ESLint, Prettier, TypeScript,
Vite, Jest, Playwright, Knip. Published as @vigdorov/* npm packages
to Gitea registry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 23:40:22 +03:00
commit cf64bf6d7d
38 changed files with 11287 additions and 0 deletions

View File

@ -0,0 +1,27 @@
{
"name": "@vigdorov/vite-config",
"version": "1.0.0",
"description": "Shared Vite configuration",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"exports": {
".": "./dist/index.js",
"./spa": "./dist/spa.js",
"./library": "./dist/library.js"
},
"scripts": {
"build": "tsc"
},
"peerDependencies": {
"vite": ">=6.0.0"
},
"dependencies": {
"@vitejs/plugin-react": "^4.5.2"
},
"devDependencies": {
"vite": "^6.3.5",
"typescript": "^5.8.3"
}
}

View File

@ -0,0 +1,2 @@
export {spa, type SpaOptions} from './spa.js';
export {library, type LibraryOptions} from './library.js';

View File

@ -0,0 +1,31 @@
import {defineConfig, type UserConfig} from 'vite';
import {resolveAliases} from './utils.js';
export interface LibraryOptions {
entry: string;
name: string;
aliases?: Record<string, string>;
external?: string[];
formats?: ('es' | 'cjs')[];
}
export function library(options: LibraryOptions): UserConfig {
const {entry, name, aliases, external = [], formats = ['es', 'cjs']} = options;
return defineConfig({
resolve: {
alias: resolveAliases(aliases),
},
build: {
lib: {
entry,
name,
formats,
fileName: (format) => `index.${format === 'es' ? 'mjs' : 'cjs'}`,
},
rollupOptions: {
external,
},
},
});
}

30
packages/vite/src/spa.ts Normal file
View File

@ -0,0 +1,30 @@
import react from '@vitejs/plugin-react';
import {defineConfig, type UserConfig} from 'vite';
import {resolveAliases} from './utils.js';
export interface SpaOptions {
port?: number;
aliases?: Record<string, string>;
proxy?: Record<string, string>;
base?: string;
outDir?: string;
}
export function spa(options: SpaOptions = {}): UserConfig {
const {port = 5173, aliases, proxy, base = '/', outDir = 'dist'} = options;
return defineConfig({
plugins: [react()],
base,
resolve: {
alias: resolveAliases(aliases),
},
server: {
port,
proxy,
},
build: {
outDir,
},
});
}

View File

@ -0,0 +1,9 @@
import path from 'node:path';
export function resolveAliases(aliases: Record<string, string> | undefined): Record<string, string> {
if (!aliases) return {};
return Object.fromEntries(
Object.entries(aliases).map(([key, value]) => [key, path.resolve(process.cwd(), value)]),
);
}

View File

@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}