我正在使用Nextjs并在_app. js中加载flaticon css,如:import '../public/assets/css/flaticon.css';
在以下内容中,我遇到错误:
@font-face {
font-family: 'Flaticon';
src: url('../fonts/Flaticon.eot');
src: url('../fonts/Flaticond41d.eot?#iefix') format('embedded-opentype'),
url('../fonts/Flaticon.woff') format('woff'),
url('../fonts/Flaticon.ttf') format('truetype'),
url('../fonts/Flaticon.html#Flaticon') format('svg');
font-weight: normal;
font-style: normal;
}
我收到以下错误:
error - ./public/assets/css/Flaticon.html
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!DOCTYPE html>
| <html lang="en-US" prefix="og: http://ogp.me/ns#">
| <head>
1条答案
按热度按时间nafvub8i1#
通过以下步骤解决此问题:
1.安装html加载程序
npm install --save-dev html-loader
1.将其添加到next.config.js文件中
参考:https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config