[英]How to implement a Next.js SVG Loader
由于 Zeit 有一个新品牌,因此没有更新:
我的代码正在运行,现在由于这个问题我什至无法运行我的网站。 如何以不同方式加载 SVG? 我试过 using.babelrc 但没有用。
代码next.config.js :
const withSass = require("@zeit/next-sass");
const withCSS = require("@zeit/next-css");
module.exports = withCSS(
withSass({
webpack(config, options) {
config.module.rules.push({
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: {
loader: "url-loader",
options: {
limit: 100000,
},
},
});
return config;
},
})
);
从 Next.js 9.3 开始,您可以使用内置的 CSS 和 SASS 支持。
有关详细信息,请参阅内置 SASS 支持。
至于svg
- 你不需要装载机。
假设您有public/foo.svg
图像,您可以在 CSS 中将其指定为url(/foo.svg)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.