laravel 5 - css file is not defined in asset manifest?

蹲街弑〆低调 提交于 2019-12-31 19:38:15

问题


I get an Error Message with laravel 5, which I don't understand.

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") }}">

What is this 'asset manifest' and how to fix this error?`


回答1:


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:

<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:

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.

It will create public/build/ folder with rev-manifest.json (this file is missing in your case).

I would recommend you to watch Managing assets Laracasts episode to understand it a bit better.




回答2:


Same issue here!! I solve it by creating production version of css. I update gulefile.js as bellow,

 elixir(function(mix) {
     mix.sass('app.scss').version('css/app.css').browserify('app.js');
 });

Then run following command which will create rev-manifest.json file in public/build directory.

 gulp --production 

Good luck!!



来源:https://stackoverflow.com/questions/28353295/laravel-5-css-file-is-not-defined-in-asset-manifest

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