对于我的管理面板,我提取所有资产,包括manifest-json.js
到mix.setPublicPath(path.normalize('public/backend/'))
。
所有文件都正确添加到后端文件夹,manifest-json.js
文件如下所示:
{
// all correct here
"/js/vendor.js": "/js/vendor.js",
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css",
"/js/manifest.js": "/js/manifest.js"
}
问题是在使用时
{{ mix('backend/css/app.css') }}
在我的刀片文件中,它看起来在public/manifest-json.js
而不是在backend/manifest-json.js
中寻找它。
如何确保使用正确的manifest-json.js
文件?
我解决了运行此命令的问题
npm install
然后
npm run production
谢谢。
在将laravel项目部署到服务器之后,我遇到了同样的异常。它在localhost上运行得非常好,但经过大量研究后我找到了解决方案。如果在服务器上遇到此异常,则必须将公共路径绑定到public_html
只需转到app / Providers下,您将找到您的AppServiceProvider文件,并在boot()方法内部进行绑定,如下所示。
$this->app->bind('path.public', function() {
return base_path().'/../public_html';
});
我遇到的问题是mix()
-helper函数默认在/public/manifest-json.js
中查找manifest-json文件,所以如果你将该文件存储在任何其他目录级别,那么它将抛出该错误。
假设manifest-json文件存储在public/app/manifest-json.js
中,然后对于位于public/app/css/app.css
中的文件,您将使用:
<link rel="stylesheet" href="{{ mix('css/app.css', 'app') }}">
mix()
-helper函数允许第二个参数,即清单文件的目录。只需在那里指定它,它将使用正确的清单文件。
在共享主机和laravel 5.6测试中:执行标准级别后,如解释here;需要两个级别:在app/Providers/AppServiceProvider.php
:
$this->app->bind('path.public', function() {
return realpath(base_path().'/../public_html');
});
并在public_html
文件中生成.htaccess
文件的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
来源:here这个文件在某些情况下变化最大。
这就是全部并解决了我的问题
我和提问者有同样的问题:manifest does not exist
解决它我所做的是运行2个命令如下:
npm install
然后
npm run dev
现在解决了错误。 yippi。
我在Laravel包中遇到了同样的问题,其资产未发布:
这解决了我的问题:
php artisan vendor:publish --tag=telescope-assets --force
资料来源:https://github.com/laravel/telescope/issues/136 https://github.com/laravel/telescope/issues/250