我在 nextjs 网站上工作,最近我添加了fontmin-webpack插件,该插件不断抛出错误fontmin/node_modules/ttf2woff2/jssrc/ttf2woff2.js:3 Invalid asm.js: Invalid member of stdlib我没有设法修复。
该网站正在使用font-family: "icomoon"; 在src/icons/style.css中定义- 我不确定这是否重要。
这是我到目前为止所做的事情:
将fontmin-webpack和file-loader添加到站点
yarn add fontmin-webpack --dev
yarn add file-loader
在next.config.js中导入依赖项
const FontminPlugin = require("fontmin-webpack"); // fontmin import
module.exports = {
compress: false,
i18n: {
locales: ["sr", "en"],
defaultLocale: "sr",
localeDetection: false
},
images: {
domains: ["..."] // there is actually a list of websites
},
webpack(config, { isServer }) {
if (!isServer) {
config.resolve.fallback.fs = false;
}
config.module.rules.push({
test: /\.(ttf|eot|svg|woff2)?(\?[a-z0-9#=&.]+)?$/,
use: [
{
loader: "file-loader" // file loader set
}
]
});
config.plugins.push(new FontminPlugin({ autodetect: true, glyphs: [] })); // plugin set
return config;
}
};
我正在使用 webpack 5,并尝试升级/降级依赖项(ttf2woff2、lodash、webpack-sources、fontmin-webpack)。或者代码中的某个地方可能存在错误。