dogma's avatar
Level 1

[vite:css] [postcss] ENOENT: on Laravel Forge Deployment

I am trying to deploy my app to Laravel Forge and bundle it with vite.

It works fine on my local dev Server without any error however the Deployment fails while building on my prod server due to not resolvable paths.

Anyone faced the same issue yet?

the error:

> build
> vite build

vite v5.4.3 building for production...
transforming...

✓ 147 modules transformed.
x Build failed in 5.64s
error during build:
[vite:css] [postcss] ENOENT: no such file or directory, open '/home/forge/website.com/resources/js/assets/fonts/quicksand-regular/7f9edfb12c4146a51e3a8b95042aeb26.ttf'
file: /home/forge/website.com/resources/css/app.css:undefined:NaN
Error: [postcss] ENOENT: no such file or directory, open '/home/forge/website.com/resources/js/assets/fonts/quicksand-regular/7f9edfb12c4146a51e3a8b95042aeb26.ttf'

the correlating part in my app.css file:

@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

* {
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

/* Fonts */
@layer base {
    @font-face {
        font-family: "Quicksand";
        src:local("Quicksand-Regular"),
        url('@/assets/fonts/quicksand-regular/7f9edfb12c4146a51e3a8b95042aeb26.ttf');
        font-weight: 400;
        font-style: normal;
        font-display: swap;
    }
}

my vite.config.mjs:

my folder structure on local:

laravelapp/resources/css/app.css
laravelapp/resources/js/assets/fonts/Quicksand-Regular/7f9edfb12c4146a51e3a8b95042aeb26.ttf

my deployment script:

cd /home/forge/website.com
git pull origin $FORGE_SITE_BRANCH

$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader

( flock -w 10 9 || exit 1
    echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock

if [ -f artisan ]; then
    $FORGE_PHP artisan migrate --force
fi

npm ci
npm run build
rm -rf node_modules
0 likes
4 replies
Tray2's avatar

to me it looks like the font file isn't deployed onto the server.

tykus's avatar

The error message is pretty clear

no such file or directory, open '/home/forge/website.com/resources/js/assets/fonts/quicksand-regular/7f9edfb12c4146a51e3a8b95042aeb26.ttf'

Did you check on the server what (if anything) is at the path /home/forge/website.com/resources/js/assets/fonts/?

Is that directory version-controlled? How/where did you get the font - is it npm-installed and symlinked, or did you download directly to your resources directory; if so, is that directory version-controlled?

dogma's avatar
Level 1

Thank you for your time..

I sshed into the server and checked for all files earlier on.

In the end the issue was solved by changing the directory name from "Quicksand-Regular" to "quicksand-regular" ........

Didn't know vite was case-sensitive

Thank you for the quick replies!

tykus's avatar
tykus
Best Answer
Level 104

@dogma Vite itself is not case sensitive, your operating system is however.

Discipline around consistent case for directories, files and even your PHP code is essential if deploying on a *nix host

Please or to participate in this conversation.