Mego's avatar
Level 1

public/js and css folder sudennly disappeared

I have developed a small system on my localhost, using WAMP. Everything went OK. Then I manually uploaded the file from my wamp/www/project to FTP - live server. When I try to run an application, the CSS and JS files are not available.

I have looked into the ftp and find, that there are no css and js folder in public/... why? Also the next mystery is, on my localhost those folders seems to work fine (probably laravel cache?), but when I look via file explorer, I can't find both folders...

What's the magic? I would like to find default js and css files distributed with laravel package. I looked also to Laravel's github repository, folder are gone... What should I do?

0 likes
15 replies
Nakov's avatar

The magic is that the files reside in the resources/js and resources/css folders. But then you use Laravel Mix in order to compile the assets, and they will magically appear in the public directory. :)

2 likes
Mego's avatar
Level 1

So I just need to use Laravel Mix for compilation and it will be OK? Could you plz give me more info about what should I write to console?

Nakov's avatar

@mego you should read the documentation, that's why I provided you with a direct link above. But yes, after you compile the assets using npm run production for example you will need to reference those files:

<script src="{{ mix('/js/app.js') }}"></script>

// and
<link href="{{ mix('/css/app.css') }}"></script>

Set the file names as per your project. They will be available in your public folder. You always change the files in the resources folder, run the npm task and then you use the compiled files from the public folder.

1 like
Mego's avatar
Level 1

What to do if I don't have and don't want to have and use npm? I don't need it :-/

Nakov's avatar

@mego then you don't want to get the advantages that webpack provides as it seems. You don't have styles and scripts? You don't want them compiled? You will use the full heavy versions of them?

Then just copy and paste them in your FTP public folder.

Mego's avatar
Level 1

Yes, but I have not that versions. :-/

Nakov's avatar

@mego if you are working with Laravel 6.0, this is a video for you, that Jeffrey released today.

jlrdw's avatar

Do you have a correct folder structure. Is main laravel above public_html. Npm is optional you can still just load your own assets any way you wish.

From docs

quote

you are free to use any asset pipeline tool you wish, or even none at all.

end quote

Myself I use a small amount of custom css, not bootstrap, I just load them like:

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

But most recommend the compiling where you are using a large amount of assets.

Mainly has to do with versioning.

Just to have it, I did download manually bootstrap.css the compiled smaller one, renamed to app.css and placed where app.css would normally go. I do not change my css often enough to worry about npm.

That way app.css is still used to style login, register, and pagination.

kixapol's avatar

I followed all what you said, but my css file is empty. Is it correct?

jlrdw's avatar

Mix node and all that stuff has nothing to do with that.

Like I said I just downloaded bootstrap and renamed app CSS and I was good to go in 2 minutes.

But where is calling what? what's your folder structure, troubleshoot your way through this, it's not that hard. Right click, view source, etc

Obviously CSS files have to be placed at a certain place to be properly used.

@nakov

You don't want them compiled? You will use the full heavy versions of them?

No bootstrap has minified also for download. So does jquery.

@mego See these:

http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet/

Has images https://laracasts.com/discuss/channels/laravel/next-issue-fonts-and-images-arent-visible

On a shared host you need correct folder structure.

kixapol's avatar

May I know what is the reference that you typed in the link. thank you

Ashley_Mok's avatar

Currently, i see both resources/js and public/build for CSS and JS files in the production

Please or to participate in this conversation.