资源模块原创
# 资源模块
# 介绍
- 用于加载除js外的其他文件
- 分为四种类型
{
test: /\.png$/, //导出url
type: "asset/resource",
generator:{
filename: "images/[contenthash][ext]" // 设置导入的资源文件夹,文件名,扩展名。优先级更高
}
}
1
2
3
4
5
6
7
2
3
4
5
6
7
# asset/resource
- 导出资源的URL
- 比如图片的路径
# asset/inline
- 导出资源的Data.URL
- 比如svg的base64码
# asset/source
- 导出资源的源代码
- 比如text文件的文本
# asset
- 导出通用资源的URL或者Data.URL
- 当资源大于8k则导出资源,小于则生成base64链接
- 通过选项parser:中的dataUrlCondition来设置转换的临界值Maxsize