javascript - 如何实现 Next.js SVG 加载器
问题描述
由于 Zeit 有一个新品牌,因此没有更新:
- @zeit/with-css
- @zeit/with-sass
我的代码正在运行,现在由于这个问题我什至无法运行我的网站。如何以不同方式加载 SVG?我尝试使用 .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)
.
推荐阅读
- xamarin.android - Xamarin Android - 工具栏问题
- python - 累积标准化直方图
- javascript - 如何更改 react-bootstrap 中按钮的颜色?
- schema.org - 如何使用 schema.org 显示子集合的集合?
- java - 两个时间戳之间的 SQL
- r - 轻松替换 R 中的多个单词;str_replace_all 给出两个对象长度不相等的错误
- javascript - 将数据保存到 Firebase 后,React 给我一个警告
- python - requirements.txt 大于等于然后小于?
- c++ - WINAPI:无法从主磁盘读取 (PhysicalDrive0)
- oracle - 在运行时更改页面类型(普通 x 模式页面)