Skip to content

Commit

Permalink
feat: treat .cur as image assets
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Jan 5, 2025
1 parent b36b20f commit 5b8f373
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -535,7 +535,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -943,7 +943,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -1277,7 +1277,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const IMAGE_EXTENSIONS: string[] = [
'tif',
'tiff',
'jfif',
'cur',
];
export const VIDEO_EXTENSIONS: string[] = ['mp4', 'webm', 'ogg', 'mov'];
export const AUDIO_EXTENSIONS: string[] = [
Expand Down
8 changes: 4 additions & 4 deletions packages/core/tests/__snapshots__/asset.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`plugin-asset > should add image rules correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -152,7 +152,7 @@ exports[`plugin-asset > should add image rules correctly 2`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -275,7 +275,7 @@ exports[`plugin-asset > should allow to use distPath.image to modify dist path 1
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -398,7 +398,7 @@ exports[`plugin-asset > should allow to use filename.image to modify filename 1`
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/__snapshots__/builder.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ exports[`should use Rspack as the default bundler > apply Rspack correctly 1`] =
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down
8 changes: 4 additions & 4 deletions packages/core/tests/__snapshots__/default.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -611,7 +611,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -1050,7 +1050,7 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -1429,7 +1429,7 @@ exports[`tools.rspack > should match snapshot 1`] = `
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down
4 changes: 2 additions & 2 deletions packages/core/tests/__snapshots__/environments.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down Expand Up @@ -1805,7 +1805,7 @@ exports[`environment config > tools.rspack / bundlerChain can be configured in e
"type": "asset",
},
],
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\)\\$/i,
"test": /\\\\\\.\\(\\?:png\\|jpg\\|jpeg\\|pjpeg\\|pjp\\|gif\\|bmp\\|webp\\|ico\\|apng\\|avif\\|tif\\|tiff\\|jfif\\|cur\\)\\$/i,
},
{
"oneOf": [
Expand Down
4 changes: 4 additions & 0 deletions packages/core/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ declare module '*.jfif' {
const src: string;
export default src;
}
declare module '*.cur' {
const src: string;
export default src;
}

/**
* Font assets
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/guide/basic/static-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Static assets are files that are part of a web application and do not change, ev

The following are the formats supported by Rsbuild by default:

- **images**: png, jpg, jpeg, gif, svg, bmp, webp, ico, apng, avif, tif, tiff, jfif, pjpeg, pjp.
- **images**: png, jpg, jpeg, gif, svg, bmp, webp, ico, apng, avif, tif, tiff, jfif, pjpeg, pjp, cur.
- **fonts**: woff, woff2, eot, ttf, otf, ttc.
- **audio**: mp3, wav, flac, aac, m4a, opus.
- **video**: mp4, webm, ogg, mov.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/guide/basic/static-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Rsbuild 支持在代码中引用图片、字体、音频、视频等类型的静

以下是 Rsbuild 默认支持的静态资源格式:

- **图片**:png、jpg、jpeg、gif、svg、bmp、webp、ico、apng、avif、tif、tiff、jfif、pjpeg、pjp。
- **图片**:png、jpg、jpeg、gif、svg、bmp、webp、ico、apng、avif、tif、tiff、jfif、pjpeg、pjp、cur
- **字体**:woff、woff2、eot、ttf、otf、ttc。
- **音频**:mp3、wav、flac、aac、m4a、opus。
- **视频**:mp4、webm、ogg、mov。
Expand Down

0 comments on commit 5b8f373

Please sign in to comment.