@@ -75,6 +75,11 @@ export type PagesInput = Record<string, PageInput>
75
75
76
76
export type Pages = Record < string , Page >
77
77
78
+ export interface Resolve {
79
+ /** 别名映射表,key 为要匹配的模块或路径,value 为(被实际使用的)目标路径 */
80
+ alias : Record < string , string >
81
+ }
82
+
78
83
export interface TransformObject {
79
84
transformer : Transform
80
85
config ?: unknown
@@ -110,6 +115,7 @@ export interface BuildConfigInput {
110
115
distDir ?: string
111
116
entries ?: Entries
112
117
pages ?: PagesInput
118
+ resolve ?: Resolve
113
119
transforms ?: TransformsInput
114
120
/** 注入到代码中的环境变量 */
115
121
envVariables ?: EnvVariables ,
@@ -123,12 +129,14 @@ export interface BuildConfigInput {
123
129
124
130
export interface BuildConfig extends Required < BuildConfigInput > {
125
131
pages : Pages
132
+ resolve : Resolve
126
133
transforms : Transforms
127
134
}
128
135
129
136
/** merge two config content */
130
137
function mergeConfig ( cfg1 : BuildConfigInput , cfg2 : BuildConfigInput ) : BuildConfigInput {
131
138
return extend ( cfg1 , cfg2 , {
139
+ resolve : extend ( cfg1 . resolve , cfg2 . resolve ) as Resolve ,
132
140
transforms : extend ( cfg1 . transforms , cfg2 . transforms ) as TransformsInput ,
133
141
envVariables : extend ( cfg1 . envVariables , cfg2 . envVariables ) ,
134
142
optimization : extend ( cfg1 . optimization , cfg2 . optimization ) as Optimization ,
@@ -265,7 +273,7 @@ function normalizeTransforms(input: TransformsInput): Transforms {
265
273
266
274
function normalizeConfig ( {
267
275
extends : _extends , publicUrl : _publicUrl , srcDir, staticDir, distDir, entries, pages : _pages ,
268
- transforms : _transforms , envVariables, optimization, devProxy,
276
+ resolve , transforms : _transforms , envVariables, optimization, devProxy,
269
277
deploy, targets, test, engines
270
278
} : BuildConfigInput ) : BuildConfig {
271
279
if ( _extends == null ) throw new Error ( 'Invalid value of field extends' )
@@ -275,6 +283,7 @@ function normalizeConfig({
275
283
if ( distDir == null ) throw new Error ( 'Invalid value of field distDir' )
276
284
if ( entries == null ) throw new Error ( 'Invalid value of field entries' )
277
285
if ( _pages == null ) throw new Error ( 'Invalid value of field pages' )
286
+ if ( resolve == null ) throw new Error ( 'Invalid value of field resolve' )
278
287
if ( _transforms == null ) throw new Error ( 'Invalid value of field transforms' )
279
288
if ( envVariables == null ) throw new Error ( 'Invalid value of field envVariables' )
280
289
if ( optimization == null ) throw new Error ( 'Invalid value of field optimization' )
@@ -288,7 +297,7 @@ function normalizeConfig({
288
297
const transforms = normalizeTransforms ( _transforms )
289
298
return {
290
299
extends : _extends , publicUrl, srcDir, staticDir, distDir, entries, pages,
291
- transforms, envVariables, optimization, devProxy,
300
+ resolve , transforms, envVariables, optimization, devProxy,
292
301
deploy, targets, test, engines
293
302
}
294
303
}
0 commit comments