-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
174 lines (166 loc) · 4.12 KB
/
types.ts
File metadata and controls
174 lines (166 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/** 资源处理插件配置项 */
export interface AssetWebpackPluginOptions {
/** 图片资源配置项 */
image?: ImageOptions
/** 字体资源配置项 */
font?: FontOptions
/** 媒体资源配置项 */
media?: MediaOptions
/** 自定义配置项 */
[key: string]: {
[key: string]: any
}
}
/** url-loader 配置项 */
export interface UrlLoaderOptions extends FileLoaderOptions {
/** 自定义配置项 */
[key: string]: any
/**
* 指定当目标文件的大小超过limit选项中设置的限制时使用的备用loader。
*
* 默认: file-loader
*/
fallback?: string | 'file-loader'
/**
* 该限制可以通过加载程序选项指定。
*
* 默认: undefined
*/
limit?: number | string | boolean
/**
* 设置要转换文件的MIME类型。
* 如果未指定,则文件扩展名将用于查找MIME类型。
*/
mimetype?: string
}
/**
* 转换资源路径
*
* @params file 文件路径
*/
type TransformPathFunction = (file: string) => string
/**
* 指定将放置目标文件的文件系统路径方法。
*
* @params url 资源输出路径
* @params resourcePath 文件的绝对路径
* @params context 全局上下文,webpack的context
*/
type PathFunction = (url: string, resourcePath: string, context: string) => string
// docs: https://github.com/webpack-contrib/file-loader
export interface FileLoaderOptions {
/**
* 输出资源名称
*
* 默认: '[contexthash].[ext]'
*/
name?: string | TransformPathFunction
/**
* 指定将放置目标文件的文件系统路径
*
* 默认: undefined
*/
outputPath?: string | PathFunction
/**
* 指定项目发布路径
*
* 默认: <__webpack_public_path__>
*/
publicPath?: string | PathFunction
/**
* 指定一个自定义函数来对生成的公共路径进行后处理。
* 这可以用于添加或添加仅在运行时可用的动态全局变量。
*
* 默认: undefined
*/
postTransformPublicPath?: TransformPathFunction
/**
* 指定自定义文件上下文。
*
* 默认: <webpack.context>
*/
context?: string
/**
* 如果为true,则发出一个文件(将文件写入文件系统)。
* 如果为false,则加载程序将返回公共URI,但不会发出文件。
* 禁用服务器端软件包的此选项通常很有用。
*
* 默认: true
*/
emitFile?: boolean
/**
* 使用正则表达式来过滤需要处理的文件
*
* 默认: undefined
*/
regExp?: RegExp
/**
* 默认情况下,文件加载器会生成使用ES模块语法的JS模块。
* 在某些情况下,使用ES模块是有益的,例如在模块module和tree shaking的情况下。
*
* 默认: false
*/
esModule?: boolean
}
/** 图片资源配置项 */
export interface ImageOptions extends UrlLoaderOptions {
/**
* 输出资源名称
*
* 默认: 'image/[name].[hash:8].[ext]'
*/
name?: string | TransformPathFunction
/**
* 使用正则表达式来过滤需要处理的文件
*
* 默认: /\.(png|jpe?g|gif|svg)(\?.*)?$/
*/
regExp?: RegExp
/**
* 该限制可以通过加载程序选项指定。
*
* 默认: 500
*/
limit?: number | string | boolean
}
/** 字体资源配置项 */
export interface FontOptions extends UrlLoaderOptions {
/**
* 输出资源名称
*
* 默认: 'fonts/[name].[hash:8].[ext]'
*/
name?: string | TransformPathFunction
/**
* 使用正则表达式来过滤需要处理的文件
*
* 默认: /\.(woff2?|eot|ttf|otf)(\?.*)?$/
*/
regExp?: RegExp
/**
* 该限制可以通过加载程序选项指定。
*
* 默认: 1e4
*/
limit?: number | string | boolean
}
/** 媒体资源配置项 */
export interface MediaOptions extends UrlLoaderOptions {
/**
* 输出资源名称
*
* 默认: 'media/[name].[hash:8].[ext]'
*/
name?: string | TransformPathFunction
/**
* 使用正则表达式来过滤需要处理的文件
*
* 默认: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/
*/
regExp?: RegExp
/**
* 该限制可以通过加载程序选项指定。
* 默认: 1e4
*/
limit?: number | string | boolean
}