纸飞机的信笺
博客Awesome开源Demos制品库样板与配置

系统

command常用命令行
vscodeVSCode

通用

licenseLICENSE 许可
editorconfigEditorConfig
gitGit
typescriptTypeScript

Agent

claudeClaude Code
codexCodex

开发配置

nextjsNext.js
viteVite
vitestVitest
postcssPostCSS
rollupRollup
eslintESLint
prettierPrettier
tailwindcssTailwindCSS

包管理

npmnpm
nodejspackage.json

代码质量

huskyHusky
commitizenCommitizen
commitlintCommitLint
lintstagedLintStaged

传统

webpackWebpack
babelBabel
craCreateReactApp

杂项

monorepoMonorepo

vitestVitest

基础配置模拟 HTTP 服务器Node.js 服务端浏览器

此 vitest.config.mts 配置文件适合 TypeScript 库。

依赖项:

npm add -D vitest

空模板如下:

import { defineConfig } from 'vitest/config'
 
export default defineConfig({
  test: {
    // 配置在这里
  },
})

如果你的包需要一些浏览器的 API,可以使用 jsdom:

依赖项:

npm add -D jsdom

配置如下:

import { defineConfig } from 'vitest/config'
 
export default defineConfig({
  test: {
    environment: 'jsdom',
  },
})

它可以模拟例如 window、localStorage 等 API。

如果你在 tsconfig.json 中定义了 compilerOptions.paths,例如 Monorepo 仓库,此时 Vitest 无法加载这些路径的文件,需要使用插件来解决。

依赖项:

npm add -D vite-tsconfig-paths

配置如下:

import tsconfigPaths from 'vite-tsconfig-paths'
import { defineConfig } from 'vitest/config'
 
export default defineConfig({
  plugins: [tsconfigPaths()],
  test: {
    // ...
  },
})

注意这个 plugins 层级在上层,不在 test 里。