0

I'm working with Laravel Valet but when adding some regular expression location that works perfectly on forge Linux server, doesn't work for MacOS. It doesn't give any errors just doesn't load any of the right css. The regex is for css/js versioning. See code below:

location ~* (.+)\.(?:\d+)\.(css|js|gif|png|jpg|jpeg)$ {
    try_files $uri $1.$2;
}

added just before

location / {
    rewrite ^ "/Users/home/.composer/vendor/laravel/valet/server.php" last;
}

in valet.conf file

latr.88
  • 849
  • 5
  • 17

2 Answers2

0

Solved by using a custom Valet Driver, it's just php and you can use it to play with the incoming request and return the desired url or response. In this case I created a LocalValetDriver in the project root folder and skip the numeric portion of the filename in the isStaticFile function, just remember to return true on the server function so your custom driver will be used.

For more info on custom drivers, feel free to visit Valet's documentation here.

latr.88
  • 849
  • 5
  • 17
-1

If you are using php 7.3 it can be because of it. Check this link

Nicolae Casîr
  • 892
  • 1
  • 10
  • 18
  • I believe it's more related to the rewrite on the next line, but can't find a way to make it work. Linux VMs are also using 7.3.x and working. – latr.88 Dec 24 '19 at 17:32
  • Just tested on my MacOS Mojave: Check this screenshot: https://i.imgur.com/O3mz1g6.png all is working fine. – Nicolae Casîr Dec 24 '19 at 17:42
  • But why did you add this part of code in valet.conf? Add it in valet/Nginx/name_of_your_site.domain – Nicolae Casîr Dec 24 '19 at 17:48
  • Also added it there, didn't make a difference. Added in general conf file cause it wouldn't affect any other site. and yes, it recognizes it but doesn't ignore the timestamps in style.284627198.css to style.css as I would expect it – latr.88 Dec 24 '19 at 18:10
  • Trying to force the browser to reload css, and—wasn't my idea—just have to deal with it at least for now – latr.88 Dec 24 '19 at 18:11