I've just tried to add FontAwesome to one of my Laravel 8 projects (using TailwindCSS). I've installed it using
npm install @fortawesome/fontawesome-free
Then added it to ./resources/css/app.css
(with my TailwindCSS imports)
@tailwind base;
@tailwind components;
@tailwind utilities;
@import '~@fortawesome/fontawesome-free/css/fontawesome.css';
@import '~@fortawesome/fontawesome-free/css/regular.css';
@import '~@fortawesome/fontawesome-free/css/solid.css';
@import '~@fortawesome/fontawesome-free/css/brands.css';
Then applied the build with
npm run production
However it is giving me a 404 Error regarding the font files. They are correctly sitting inside the ./public/fonts
directory but the compiled css file is looking for them in the web servers root directory.
If I manually change the compiled css file to replace
src: url(/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot?08f9891a6f44d9546678133ab121fc54);
with
src: url(../fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot?08f9891a6f44d9546678133ab121fc54);
Then it works fine, how can I specify the FontAwesome dir so that I don't have to do this manual edit?
UPDATE
After some digging I found the file ./node_modules/laravel-mix/src/config.js
which has the following code
fileLoaderDirs: {
images: 'images',
fonts: 'fonts'
},
This seems to be where FontAwesome is getting it's dir from but is there any way to override it?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…