Laravel 5.7 中引入 font-awesome

hustnzj發表於2018-10-15

laravel 5.7 自帶bootstrap4,但bootstrap4不自帶Fontawesome,很多好看的圖示無法使用了。。如何解決?

Package managers like npm and yarn are probably familiar tools for you and your team. With them, you can easily upgrade to newer versions of Font Awesome when they are released and better manage access to Pro packages.

You can easily install the latest free version of Font Awesome via npm or yarn:

npm install --save-dev @fortawesome/fontawesome-free

or

yarn add --dev @fortawesome/fontawesome-free

Edit the resources/sass/app.scss

//font-awesome
@import "~@fortawesome/fontawesome-free/scss/fontawesome";
@import "~@fortawesome/fontawesome-free/scss/brands.scss";
@import "~@fortawesome/fontawesome-free/scss/regular.scss";
@import "~@fortawesome/fontawesome-free/scss/solid.scss";
@import "~@fortawesome/fontawesome-free/scss/v4-shims.scss";

這裡引入了5個scss檔案,不知道有沒有更簡單的辦法?

Edit the webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')

Go to terminal, run the following command

npm run watch-poll

Reference the public/css/app.css in the of page which u want to introduce Font Awesome

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

All Done!

安裝Font-awesome

相關文章