3

I've installed font-awesome using npm install font-awesome --save-dev, and now Im having trouble including it on my project. Below are my code.

webpack.config.js

{
            test: /\.(svg|woff|woff2|ttf|eot|otf)$/,
            loader: 'file-loader?name=assets/[name].[ext]',
}

app.scss

$fa-font-path: "~font-awesome/fonts";
@import "~font-awesome/scss/font-awesome.scss";

Error

ERROR in ./~/font-awesome/fonts/fontawesome-webfont.eot?v=4.7.0 Module parse failed: /ProjectSite/node_modules/font-awesome/fonts/fontawesome-webfont.eot?v=4.7.0 Unexpected character '�' (1:1) You may need an appropriate loader to handle this file type.

3 Answers 3

5

By reading doing some research I finally solved it by adding ([\?]?.*)$ on the regex part.

{
     test: /\.(svg|woff|woff2|ttf|eot|otf)([\?]?.*)$/,
     loader: 'file-loader?name=assets/fonts/[name].[ext]',
}
Sign up to request clarification or add additional context in comments.

Comments

1

Have you installed the npm file-loader package?

npm install --save-dev file-loader

I have a webpack example repository in which I include font-awesome. It might help. You can find it here

1 Comment

yes I have installed file-loader but still dont work
0

with new webpack versions you may wanna try

{
    test: /\.(svg|woff|woff2|ttf|eot|otf)([\?]?.*)$/,
    use: [
        {
            loader: 'file-loader?name=assets/fonts/[name].[ext]'
        }
    ]
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.