1

I'm writing a program using laravel. To manage css and js, I used versioning and call it with a function like this
<link rel="stylesheet" href="{{ mix('/css/app.css') }}">
The code above produces html output as follows
<link rel="stylesheet" href="/css/app.css?id=53a226b301fc510ddf79">

When I upload to hosting, why does the above code only produce html like this ?
<link rel="stylesheet" href="/css/app.css"> (the mix-manifest.json / id file not load)

this is my localhost enter image description here

and this is on the hosting enter image description here

Tony
  • 9,672
  • 3
  • 47
  • 75
  • 1
    could you please show your `webpack.mix.js`? also your Laravel version? – DengSihan Oct 29 '21 at 01:49
  • mix.version(); mix.js('resources/js/app.js', 'public/js') // .sass('resources/scss/app.scss', 'public/css') .postCss("resources/css/app.css", "public/css", [ require("tailwindcss"), ]); I use laravel 8.4 – Fernanda Akhsanuddin Oct 30 '21 at 11:29
  • Which hosting environment are you using? I'm assuming you upload the source code to a repo and it builds from that, rather than uploading the files you complied locally. – Tony Oct 31 '21 at 21:38

2 Answers2

0

Did you run npm run dev after deploy it on your hosting? Make sure in your webpack.mix.js have .version() method.

Tra Lee
  • 113
  • 1
  • 8
0

I think in your localhost your laravel run in development mode. And in the hosting the laravel run with production mode. Check your .env file.

DevinE
  • 149
  • 1
  • 4
  • Yes. On localhost, the env value is local. When I change the env value to production, the versioning doesn't run. Then, does the env value on the hosting have to be local? – Fernanda Akhsanuddin Nov 03 '21 at 01:23
  • Yes. If you want to the versioning run, the env value on the hosting have to be local. Because in `local` browser will not cache js file. – DevinE Nov 03 '21 at 01:27
  • In production, Js caching is important, It will affect the speed of the website – DevinE Nov 03 '21 at 01:29