Laravel Mix - 当localhost上的网站不在根文件夹中时,URL处理工作错误

问题描述 投票:0回答:2

Web服务器结构:

localhost/my_site_folder/public

当我在我的scss文件中使用url(../ images / example.png)时,mix会自动找到example.png,将其复制到我的public / images文件夹,然后在我生成的样式表中重写url()(https://laravel.com/docs/5.6/mix#url-processing

很酷的功能,一切似乎都很好,除了事实,这个链接是在docs background: url(/images/example.png?d41d8cd98f00b204e9800998ecf8427e);中描述的那样生成的,但在我的情况下,这个链接是localhost/images/example.png?d41d8cd98f00b204e9800998ecf8427e,但我需要localhost/my_site_folder/public/images/example.png?d41d8cd98f00b204e9800998ecf8427e

我无法找到我可以在哪里设置我的网站根文件夹路径。

附:例如,在laravel中它可以通过.env文件APP_URL = http://localhost/my_site_folder/public完成

混合中是否有类似的东西?

css laravel laravel-5 sass mix
2个回答
1
投票

这样做的技巧mix.setResourceRoot("../")。感谢Namoshek的评论。


0
投票

也许

php artisan storage:link

会是答案吗? https://laravel.com/docs/5.6/filesystem

© www.soinside.com 2019 - 2024. All rights reserved.