新增根 biome.json(v2.5,v2 起原生支持 monorepo,子包自动向上查找):
- formatter: 2 空格缩进、单引号、行宽 100、LF、尾逗号、箭头函数括号
(匹配现有代码风格)
- linter: recommended preset + 项目化裁剪
- useTemplate/useTemplate off(geometry.ts 故意保留字符串拼接,
且测试用精确浮点断言锁定行为)
- noNonNullAssertion off(测试与 DOM 访问里的 ! 是惯用写法)
- noConsole off(4 个 lib 用 console.error/warn 做错误上报)
- CSS 关闭 noDescendingSpecificity/noDuplicateProperties
(手写 CSS 的 fallback 模式)
- useImportType/useNodejsImportProtocol/noUnusedVariables warn
- vcs.useIgnoreFile 自动读 .gitignore;排除 public/target/node_modules/
dist/.dioxus/static + Tailwind 入口 input.css(含 @theme 等 Biome 无法
解析的 at-rules)
首次格式化覆盖 29 个源文件:import 排序、node: 协议、引号/缩进统一,
并修复 index.ts 两处 forEach 回调隐式返回值(useIterableCallbackReturn)。
90 个 vitest 用例全绿,确认无语义改动。
28 lines
818 B
TypeScript
28 lines
818 B
TypeScript
import { resolve } from 'node:path';
|
||
import { defineConfig } from 'vite';
|
||
|
||
export default defineConfig({
|
||
build: {
|
||
// 输出直写 public/codemirror/,Dioxus 直接托管,无需拷贝步骤。
|
||
outDir: resolve(__dirname, '../../public/codemirror'),
|
||
emptyOutDir: true,
|
||
lib: {
|
||
entry: resolve(__dirname, 'src/index.ts'),
|
||
// IIFE 产物挂在 window.CodeMirrorEditor 上,Rust 侧用 Reflect::get 取。
|
||
name: 'CodeMirrorEditor',
|
||
fileName: () => 'editor.js',
|
||
formats: ['iife'],
|
||
},
|
||
rolldownOptions: {
|
||
output: {
|
||
// 默认导出(对象字面量 { create() })成为 window.CodeMirrorEditor。
|
||
exports: 'default',
|
||
assetFileNames: 'editor.[ext]',
|
||
},
|
||
},
|
||
cssCodeSplit: false,
|
||
minify: true,
|
||
sourcemap: true,
|
||
},
|
||
});
|