webpack fontawesome configuration

Install font-awesome
npm install font-awesome --save-dev


configure webpack.config.js
module: {
        loaders: [
          {
                test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
		use: [{
			loader: 'file-loader',
			options: {
				name: '[name].[ext]',
				outputPath: 'fonts/', // output directory
				publicPath: '../' // override default directory
			}
		}]
            }
        ]
}



After editing, the fonts folder




appears in the directory, and a reference is added to the entry file
require('font-awesome/css/font-awesome.css');


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326511107&siteId=291194637