From f2b920b2186242daa8f940ebf4029b164666d811 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 29 Apr 2023 08:13:32 +0200 Subject: [PATCH] add image metadata for svg (#48947) ### What? add .svg to the list of images that that return metadata ### Why? .svg files should also return width and height ### How? see https://github.com/vercel/turbo/pull/4741 --- .../next-core/src/next_shared/transforms.rs | 1 + .../next/image/basic/input/pages/index.js | 18 ++++++++++++++++++ .../next/image/basic/input/public/test.svg | 13 +++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/public/test.svg diff --git a/packages/next-swc/crates/next-core/src/next_shared/transforms.rs b/packages/next-swc/crates/next-core/src/next_shared/transforms.rs index 00233c6f70ea..f7b6ab2bb128 100644 --- a/packages/next-swc/crates/next-core/src/next_shared/transforms.rs +++ b/packages/next-swc/crates/next-core/src/next_shared/transforms.rs @@ -95,6 +95,7 @@ pub fn get_next_image_rule() -> ModuleRule { ModuleRuleCondition::ResourcePathEndsWith(".avif".to_string()), ModuleRuleCondition::ResourcePathEndsWith(".apng".to_string()), ModuleRuleCondition::ResourcePathEndsWith(".gif".to_string()), + ModuleRuleCondition::ResourcePathEndsWith(".svg".to_string()), ]), vec![ModuleRuleEffect::ModuleType(ModuleType::Custom( StructuredImageModuleTypeVc::new().into(), diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js index 6f6156580faa..38c717c02795 100644 --- a/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/input/pages/index.js @@ -1,6 +1,7 @@ import Image from 'next/image' import { img } from '../components/img' import broken from '../public/broken.jpeg' +import svg from '../public/test.svg' import { useEffect } from 'react' export default function Home() { @@ -16,6 +17,7 @@ export default function Home() { src={img} placeholder="blur" />, + test svg image, test src image + + + + + +