配置 API
defineConfig
稳定性:Stable
ts
import { defineConfig } from '@vureact/compiler-core';
export default defineConfig({
input: 'src',
exclude: ['src/main.ts'],
});defineConfig(options) 本质上返回原对象,用于类型提示与配置约定统一。
CompilerOptions
核心字段:
root?: string项目根目录。input?: string输入文件或目录。exclude?: string[]排除规则(glob)。cache?: boolean是否启用缓存。recursive?: boolean是否递归扫描。watch?: boolean是否 watch(CLIwatch命令会设置为true)。preprocessStyles?: boolean是否预处理 less/sass。output?: { workspace, outDir, bootstrapVite, ignoreAssets }输出行为。format?: { enabled, formatter, prettierOptions }产物格式化。plugins?: { parser, transformer, codegen, ...final }分阶段插件。logging?: { enabled, warnings, info, errors }日志控制。onSuccess?: () => Promise<void>首次全量编译成功后执行。onChange?: (event, unit) => Promise<void>watch 模式增量回调。
推荐最小配置
ts
import { defineConfig } from '@vureact/compiler-core';
export default defineConfig({
input: 'src',
exclude: ['src/main.ts'],
output: {
workspace: '.vureact',
outDir: 'dist',
bootstrapVite: true,
},
cache: true,
});注意
- 渐进迁移场景强烈建议排除 Vue 入口文件。
bootstrapVite在单文件编译场景会被自动跳过。plugins中未归类键会在编译末阶段执行。
