0

I am trying to build my project using webpack and thus far I am loving it. However, now that I am trying to include font-awesome, it is annoying me quite a bit.

I have installed font-awesome through npm, and I have imported it into my project using import 'font-awesome/css/font-awesome.css'. Webpack then tries to include that file, but fails to find the appropriate loader for the font files. Here is my webpack.config.js:

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

var extractScss = new ExtractTextPlugin('bundle.css');

module.exports = {
    entry: './app/app.tsx',
    output: {
        path: 'dist',
        filename: 'bundle.js'
    },
    resolve: {
        extensions: ['', '.ts', '.js', '.tsx']
    },
    devtool: 'source-map',
    module: {
        loaders: [
            {
                test: /\.ts(x?)$/,
                loader: 'babel?presets[]=es2015!ts'
            },
            {
                test: /\.scss$/,
                loader: extractScss.extract(['css', 'sass'])
            },
            {
                test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: 'url?limit=10000&minetype=application/font-woff'
            },
            {
                test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: 'file'
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: 'app/index.ejs',
            inject: false,
            appMountId: 'root'
        }),
        new ExtractTextPlugin('bundle.css')
    ]
};
muuk
  • 932
  • 1
  • 7
  • 15
  • Can you try https://www.npmjs.com/package/font-awesome-webpack ? – Juho Vepsäläinen Feb 26 '16 at 18:06
  • `font-awesome-webpack` still requires you to manually specify the loaders. Since that is the part that doesn't work, this package wouldn't do me any good (unless I am wrong about its functionality) – muuk Feb 26 '16 at 18:11
  • Ah, yeah. Maybe you can ask the plugin author for more tips. One option is to go through something like fontello and load the fonts it generates. – Juho Vepsäläinen Feb 26 '16 at 18:41

0 Answers0