laravel 5 - 资产清单中未定义 css 文件? [英] laravel 5 - css file is not defined in asset manifest?

查看:24
本文介绍了laravel 5 - 资产清单中未定义 css 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 laravel 5 中收到一条错误消息,我不明白.

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.

我还没有安装任何资产管道或其他东西.刚刚使用 elixir 编译、缩小并将 scss 文件版本化为 all.css 并使用 <link rel="stylesheet" href="{{ elixir("css/all.css") }}">

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?`

推荐答案

问题当然是你想要达到什么.

The question is of course what you want to achieve.

如果你只是简单的把all.css文件放到public/css目录下,想要显示这个文件,可以使用:

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

但是,如果您打算修改此文件并且不希望出现缓存问题,则可以将此 all.css 文件再次放入 public/css 然后放入 gulpfile.js:

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');
});

现在你需要运行:

gulp

在你的终端中,现在你可以使用

in your terminal, and now you can use

<link rel="stylesheet" href="{{ elixir('css/all.css') }}" />

就像您之前在 HTML 中所做的那样.

as you previously did in your HTML.

它将使用 rev-manifest.json 创建 public/build/ 文件夹(您的情况下缺少此文件).

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

我建议您观看 管理资产 Laracasts 剧集稍微理解一下.

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

这篇关于laravel 5 - 资产清单中未定义 css 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆