douan7601 2016-10-08 20:38
浏览 78

Laravel 5.2未找到css和js文件的异常

I have set up a laravel 5.2 project on a vps which uses cpanel.

I've configured the subdomain to point to the public folder within the subdomain folder and the app loads as expected.

However my login page is unable to load any assets - it comes up with an not found http exception for any of the assets.

for example: http://subdomain.domain.co.uk/css/app.css.

Once I log in the assets load correctly in all other pages - just not the log in one. If I then log out and log in again then the assets all load correctly.

Just not sure what's stopping the assets loading and for laravel to try and treat a path to a css file as a route.

Any help appreciated

Additional Information:

Here's the mark up for including the css:

<link rel="stylesheet" href="/css/app.css">

I've also tried:

<link rel="stylesheet" href="{!! asset('css/app.css') !!}">

This is identical to the pages that load the assets once logged in.

Folder Structure

Root/ (a few folders for brevity)

subdomain
    app/
        http/
            routes.php
    public/
        css/
            app.css
        js/
            app.js
    vendor

The server points to `subdomain\public' as normal laravel setup

It's still happening each time the cache is cleared and only corrects once logged in and only affects the login page

  • 写回答

1条回答

  • ds1379551 2016-10-16 21:12
    关注

    I am noticing that on L5.2 in the public directory it does not include a CSS folder.

    Here is the repo's folder for reference: https://github.com/laravel/laravel/tree/5.2/public

    This leads me to believe the assets need to be initially compiled via a gulp command which will run Laravel's Elixer and generate the assets.

    From the projects root folder run

    gulp or sudo gulp

    Take note, if you have not pulled in the assets you will have to run

    npm install or sudo npm install first. Here is the out the box NPM packages pulled for reference: https://github.com/laravel/laravel/blob/5.2/package.json.

    And if you cannot install using npm you will need to install node.js first.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器