csstools/postcss-font-magician

webpack+postcss Unexpected character error

artelse opened this issue · 1 comments

Am trying to use pfm with webpack and postcss. I've added require('postcss-font-magician')({hosted: ['./src/fonts']}) to my postcss.config.js file.

But then webpack complains:
ERROR in ./fonts/fontello.woff2 Module parse failed: Unexpected character '' (1:4) You may need an appropriate loader to handle this file type. (Source code omitted for this binary file)

In webpack, postcss is loaded as such:
test: /\.css$/, use: ExtractTextPlugin.extract({ use: [ { loader: 'css-loader', options: { importLoaders: 1 } }, { loader: 'postcss-loader' } ] }) },

What might be happening is that the ExtractTextPlugin tries to parse the actual font files? Any idea how to resolve this?

zjijz commented

You need to open the font file types using file-loader or whatever other loader you want.