Skip to content

Commit 73f24a2

Browse files
committed
feat: add caseSensitivePaths config option to control path sensitivity
1 parent 55b9b0c commit 73f24a2

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

packages/bundler-shared-config/src/config/caseSensitivePaths.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { CHAIN_ID } from '@kmijs/bundler-shared'
44
import type { SharedConfigOptions } from '../types'
55

66
export function applyCaseSensitivePaths(opts: SharedConfigOptions) {
7-
const { config } = opts
7+
const { config, userConfig } = opts
8+
9+
// 如果用户明确设置为 false,则跳过插件应用
10+
if (userConfig.caseSensitivePaths === false) {
11+
return
12+
}
13+
814
// 文件大小写
915
config.plugin(CHAIN_ID.PLUGIN.CASE_SENSITIVE_PATHS).use(CaseSensitivePaths)
1016
}

packages/bundler-shared-config/src/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ export interface IUserConfig {
167167
host?: string
168168
port?: number
169169
}
170+
171+
/**
172+
* 是否启用文件路径大小写敏感检查
173+
* @default true
174+
*/
175+
caseSensitivePaths?: boolean
170176
}
171177

172178
export interface SharedConfigOptions {

packages/preset-bundler/src/features/configPlugins/schema.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ export const schema = defineKmiConfigSchema({
99
.boolean()
1010
.optional()
1111
.describe('关闭不存在的导出或存在冲突的重导出时报错校验, 默认开启'),
12+
caseSensitivePaths: ({ zod }) =>
13+
zod
14+
.boolean()
15+
.optional()
16+
.describe('是否启用文件路径大小写敏感检查,设置为 false 可关闭检查'),
1217
})
1318

14-
export const configDefaults: Record<string, any> = {}
19+
export const configDefaults: Record<string, any> = {
20+
caseSensitivePaths: true,
21+
}

0 commit comments

Comments
 (0)