laravel 5 - 资产清单中未定义 css 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28353295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
laravel 5 - css file is not defined in asset manifest?
提问by haheute
I get an Error Message with laravel 5, which I don't understand.
我收到了 laravel 5 的错误消息,我不明白。
Next exception 'ErrorException' with message 'File build/css/all.css not
defined in asset manifest.
I haven't installed any asset pipeline or something. Just used elixir to compile, minify and version the scss-file to all.css
and included it into the master view with <link rel="stylesheet" href="{{ elixir("css/all.css") }}">
我还没有安装任何资产管道或其他东西。刚刚使用 elixir 将 scss 文件编译、缩小和版本化,all.css
并将其包含到主视图中<link rel="stylesheet" href="{{ elixir("css/all.css") }}">
What is this 'asset manifest' and how to fix this error?`
这个“资产清单”是什么以及如何解决这个错误?`
回答by Marcin Nabia?ek
The question is of course what you want to achieve.
问题当然是你想要达到的目标。
If you simply put all.css
file into the public/css
directory and you want to display this file, you can use:
如果您只是将all.css
文件放入public/css
目录中并希望显示此文件,则可以使用:
<link rel="stylesheet" href="{{ asset('css/all.css') }}" />
However if you plan to modify this file and you don't want to have caching issues, you can put this all.css
file again into public/css
then put into gulpfile.js
:
但是,如果您打算修改此文件并且不想出现缓存问题,则可以将此all.css
文件再次放入public/css
然后放入gulpfile.js
:
var elixir = require('laravel-elixir');
elixir(function(mix) {
mix.version('public/css/all.css');
});
Now you'll need to run:
现在你需要运行:
gulp
in your terminal, and now you can use
在您的终端中,现在您可以使用
<link rel="stylesheet" href="{{ elixir('css/all.css') }}" />
as you previously did in your HTML.
就像您之前在 HTML 中所做的那样。
It will create public/build/
folder with rev-manifest.json
(this file is missing in your case).
它将创建public/build/
文件夹rev-manifest.json
(在您的情况下缺少此文件)。
I would recommend you to watch Managing assets Laracasts episodeto understand it a bit better.
我建议您观看管理资产 Laracasts 一集以更好地理解它。
回答by Jakir Hosen Khan
Same issue here!! I solve it by creating production version of css. I update gulefile.js as bellow,
同样的问题在这里!!我通过创建 css 的生产版本来解决它。我更新 gulefile.js 如下,
elixir(function(mix) {
mix.sass('app.scss').version('css/app.css').browserify('app.js');
});
Then run following command which will create rev-manifest.jsonfile in public/builddirectory.
然后运行以下命令,这将在public/build目录中创建rev-manifest.json文件。
gulp --production
Good luck!!
祝你好运!!