Laravel-mix: Laravel-mix: how to change fonts build directory

Created on 18 Dec 2018  Â·  10Comments  Â·  Source: JeffreyWay/laravel-mix

Problem solved mix 4.0

stale

Most helpful comment

I don't care where my fonts are being placed in public/fonts directory as long as they are being loaded by browser correctly.

Good for you. Your answer isn't related with my question..

All 10 comments

I don't care where my fonts are being placed in public/fonts directory as long as they are being loaded by browser correctly.

I don't care where my fonts are being placed in public/fonts directory as long as they are being loaded by browser correctly.

Good for you. Your answer isn't related with my question..

There is a $fa-font-path variable in font-awesome. You can change the output path, just add to your scss before font-awesome import but I'm not sure if laravel mix can copy them to new folder for you. You may have to copy font files from node_modules via mix.copyDirectory()

It's not related to font-awesome, I'm talking about fonts in general. I just need change the path... How?

I wonder that myself. I would like to publish fonts to public/assets/fonts. I tried to mix.copy public/fonts to public/assets/fonts but that does not fix the font file paths in the compiled css files (url(/fonts…).

Overwrite fileLoaderDirs.fonts in webpack.mix.js worked for me:

let mix = require('laravel-mix');
mix.config.fileLoaderDirs.fonts = 'assets/fonts';

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Overwrite fileLoaderDirs.fonts in webpack.mix.js worked for me:

let mix = require('laravel-mix');
mix.config.fileLoaderDirs.fonts = 'assets/fonts';

Since the version 6, this solution not working anymore. Do:

let mix = require('laravel-mix');
mix.options({
    fileLoaderDirs:  {
        fonts: 'assets/fonts'
    }
});

Overwrite fileLoaderDirs.fonts in webpack.mix.js worked for me:

let mix = require('laravel-mix');
mix.config.fileLoaderDirs.fonts = 'assets/fonts';

Since the version 6, this solution not working anymore. Do:

let mix = require('laravel-mix');
mix.options({
    fileLoaderDirs:  {
        fonts: 'assets/fonts';
    }
});

Thank you @ytilotti! fyi it might be a typo (comma instead of semicolon), best

let mix = require('laravel-mix');
mix.options({
    fileLoaderDirs:  {
        fonts: 'assets/fonts',
    }
});

Thanks @michaldoda, I edited! A beautiful typing error^^

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nezaboravi picture nezaboravi  Â·  3Comments

terion-name picture terion-name  Â·  3Comments

Micaso picture Micaso  Â·  3Comments

RomainGoncalves picture RomainGoncalves  Â·  3Comments

sdebacker picture sdebacker  Â·  3Comments