less-loader: Problem with font-awesome
Here is the errors:
ERROR in ./~/font-awesome/fonts/fontawesome-webfont.woff2?v=4.4.0
Module parse failed: C:\OpenServer\domains\react-hot-boilerplate\node_modules\font-awesome\fonts\fontawesome-webfont.woff2?v=4.4.0 Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./~/css-loader!./~/less-loader!./src/_styles/styles.less 6:92564-92646
ERROR in ./~/font-awesome/fonts/fontawesome-webfont.woff?v=4.4.0
Module parse failed: C:\OpenServer\domains\react-hot-boilerplate\node_modules\font-awesome\fonts\fontawesome-webfont.woff?v=4.4.0 Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
@ ./~/css-loader!./~/less-loader!./src/_styles/styles.less 6:92677-92758
Here is my conf
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
module: {
loaders: [{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
include: path.join(__dirname, 'src')
}, {
test: /\.less$/,
loader: 'style!css!less'
}, {
test: /\.(jpe?g|gif|png|eot|svg|woff2|ttf)$/,
loader: 'file'
}]
}
};
any suggestions? Maybe I need some preLoader?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 20
Commits related to this issue
- For https://github.com/webpack-contrib/less-loader/issues/53 — committed to mWater/build-library by grassick 4 years ago
The file-loader isn’t matching the font url due to the passed arguments, ?v=4.4.0, at the end.
I use the following to catch the any passed arguments, notice the (?.*$|$) instead of a plain $
I think I was getting this issue due to the url being too long as well as the regex being off.
This seems to have fixed it for me although I suspect the regex @hoffin posted would work too:
I was bundling the scss with my own scss file, so I found that overriding the font path default variable worked for me:
Also, the loader config listed here has a nice regex test: https://www.npmjs.com/package/font-awesome-webpack-2
Did this end up getting resolved? I am also having this issue, even with using the solution @hoffin suggested. Here are my loaders:
And here is the error I am receiving:
I’m using webpack 2.2.1^ and i had to use this confguration:
@fellz Moving the
$|$)
end of line outside of the capture group like so/\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif)(\?\S*)?$/
yields the same result with less redundancy.@ alexsasharegan - Your solution to change the variable in the font awesome _variables.scss worked for me dude!
old value: $fa-font-path: “…/fonts” new value: $fa-font-path: “~font-awesome/fonts/”;
My setup: NG CLI created barebones project that I added font awesome to.
@alexsasharegan your solution worked for me! thanks a bunch!
Node JS: Install the below command npm i --save @fortawesome/fontawesome
I use the Font Awesome module, and here’s what worked for me :
output:
publicPath: '/',
module.rules:
using the copy-webpack-plugin and the extract-text-webpack-plugin, add this to plugins:
I also had a similar error when I had
I resolved the issue by adding
to the
include
array.I encountered this issue But according to answer I has fixed this issue Thanks