webpack加载下载自阿里巴巴iconfont字体库的字体文件出错
跟着Materliu老师用react实现画廊应用,做到导航条部分的时候使用iconfont,在样式文件中书写了以下声明:
@font-face {
font-family: "iconfont";
src: url('../fonts/iconfont.eot'); /* IE9*/
src: url('../fonts/iconfont.eot?#iefix') format('embedded-opentype'); /* IE6-IE8 */
src: url('../fonts/iconfont.woff') format('woff'); /* chrome, firefox */
src: url('../fonts/iconfont.ttf') format('truetype'); /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
src: url('../fonts/iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
}
结果发现字体文件加载错误。错误信息如下,有知道错在哪里么?
(unknown) ./src/fonts/iconfont.ttf Module parse failed:
C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\src\fonts\iconfont.ttf
Unexpected character '' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '' (1:0) at Parser.pp$4.raise (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15) at Parser.pp$7.getTokenFromCode (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2756:10) at Parser.pp$7.readToken (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2477:17) at Parser.pp$7.nextToken (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:2468:15) at Parser.parse (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:515:10) at Object.parse (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\node_modules\acorn\dist\acorn.js:3098:39) at Parser.parse (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\lib\Parser.js:902:15) at NormalModule.<anonymous> (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack\lib\NormalModule.js:104:16) at NormalModule.onModuleBuild (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10) at nextLoader (C:\Users\612226\Documents\html5\reactJS\projects\YesGalleryByReact\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25) @ ./~/css-loader!./~/_autoprefixer-loader@3.2.0@autoprefixer-loader?{browsers:["last 2 versions"]}!./~/_sass-loader@6.0.6@sass-loader/lib/loader.js?outputStyle=expanded!./src/styles/App.scss 6:359-391