Laravel Elixir wrong paths

假如想象 提交于 2019-12-06 10:05:12

That's because you're running the Laravel project on localhost. When you deploy the project to a server, the problem resolves itself (assuming it's configured correctly).

If you're using Apache, you can add a Virtual Host configuration so that instead of http://localhost:8080/laravel/public you can use something like http://domain-name.app:

<VirtualHost *:80>   
    DocumentRoot "C:\Users\username\path\to\laravel\public" 
    ServerName domain-name.app
</VirtualHost>

And then in your hosts file add:

127.0.0.1   domain-name.app

This way, you can link to absolute paths in your HTML like /css/somefile.css instead of ./css/somefile.css.

Checkout Homestead, from Laravel, it helps to avoid a lot of pain in the ass.

FWIW... you can also wrap the elixir tags with URL::asset like this:

<link href="{{ URL::asset(elixir('css/app.css')) }}" rel="stylesheet">

That solved my issue and still allowed me to run on port 8888.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!