I was trying to change the background color of the body in the css file but I noticed that it didn't work.
If this is a fresh install of Laravel, you'll want to run npm install. to install all of the front-end assets (css, js etc). If you have never made any changes to the css or js, in a terminal you'll need to run this command: npm run dev or npm run watch. Here is more documentation for Laravel Mix.
You won't want to touch the actual .css file; it will get overwritten whenever the assets compile. Using the commands above will re-compile all of the .scss files into .css.
Hope this helps!
Answer from Damon on Stack OverflowI was trying to change the background color of the body in the css file but I noticed that it didn't work.
If this is a fresh install of Laravel, you'll want to run npm install. to install all of the front-end assets (css, js etc). If you have never made any changes to the css or js, in a terminal you'll need to run this command: npm run dev or npm run watch. Here is more documentation for Laravel Mix.
You won't want to touch the actual .css file; it will get overwritten whenever the assets compile. Using the commands above will re-compile all of the .scss files into .css.
Hope this helps!
You need to compile the assets. (assume you have already installed npm)
Run
npm run prod - if production
OR
npm run dev - if development
Also you can change the colors in the file resources/sass/_variables.scss before compiling the assets.
Your assets are stored under your views, but you are linking to public.
Put the assets that you need to load (css, imgs, js) under public. Then you can simply
{{asset('css/style.css')}}
for example.
Also make sure your config/app.php document root is setup right, and if using apache, make sure that your vhost is setup properly to where /public/ is your Document Root.
For using laravel with Vite
@vite("resources/css/app.css")
CSS file not being served (Not Found, 404) in HMR
Laravel css/js gives 404 but the files exist - Stack Overflow
Laravel 6 css and js files not found ( net::ERR_ABORTED 404 (Not Found) )
Laravel 8 - GET http://localhost:8000/css/app.css net::ERR_ABORTED 404 (Not Found) - Stack Overflow
It looks like you are rewriting /images to /public/img. 'public' is the webroot so presumably the request is going to /public/public/img...
But it looks like these rules aren't being applied at all because the /img path would have the same issue. Check the body of the 404 response. If it contains HTML for the 404 page returned by Laravel then this is the case.
Either way those lines are not really needed. If you want /images to return stuff in /public/img, then you should create a symlink from /public/images to /public/img.
I think you should improve your .htaccess file.
I suggest using this:
RewriteEngine On
RewriteRule !\.(js|gif|jpg|png|css|txt)$ public/index.php [L]
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [NC,L]
That works pretty fine for me.
in laravel 6 and after version you must install ui . run below code in artisan
composer require laravel/ui --dev
php artisan ui bootstrap
php artisan ui bootstrap --auth
npm install
npm run dev
I think your css file link is not properly written
use <a href = "{{asset('//your public path location')}}" />
try this before running your project on server make sure to compile laravel-mix
npm install
and then run
npm run dev
your facing the error because app.css not compiled yet
Make sure you compile your css imports properly in resources/css/app.css first. It should look something like this:
// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
// Bootstrap
@import 'bootstrap';
// Font Awesome
@import '@fortawesome/fontawesome-free';
Then, run this on your terminal: npm run dev. This will in turn, compile your app.css in your public/css. If you are making custom css definitions, i suggest using a custom.css and putting it in your public/css folder, and define it BELOW your app.css, like:
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link href="{{ asset('css/custom.css') }}" rel="stylesheet">
Assets must always be in the public folder so they can be seen by the {{asset ('') }} command.
By default the asset() helper starts with the /public folder. If you have already taken this into consideration then the only problem will be that you have not run npm run dev.
public/
|--- css/app.css
|---js/
<link href="{{asset('css/app.css')}}" rel="stylesheet" type="text/css"> = public/css/app.css
Check your asset url in .env file. If it is missing add it in your .env file
ASSET_URL=public
and run php artisan config:cache.
My setup was a little wrong, I mostly forgetting to run npm install and npm run dev command that is required to compile the app.js and app.css files.
Correct setup command sequence was:
laravel new cms
cd cms
php artisan migrate
composer require laravel/ui
npm install
php artisan ui vue --auth
npm install && npm run dev
The app.css and app.js were missing from a new app. The proper steps had been run as are noted in Jack Robson's answer above. I reran the last two steps:
php artisan ui vue --auth
npm install && npm run dev
And it generated the app.css and app.js - all good now.
No idea what had gone wrong in the initial install.
I've just created a landing page using a Tailwind tool which exported a .zip file and I want to integrate it with my local Laravel instance. As I've all ready done the tutorials I have created a new Route with blade file (just basically copy/pasted everything from the HTML file as a proof of concept - it's my first time).
Anyway the page shows but the next challenge is defining the links to the CSS and JS files. I'm a little confused because my install has a 'resources/' folder with css and js folders... and also a 'public' folder... (but isn't css and js public files anyway). In either case I have tried to upload files to both and test them but they don't work... as in when I go directly to either link e.g. http://127.0.0.1:8000/public/robots.txt I just get a 404 page...
https://share.getcloudapp.com/GGuKzG76
This also accounts for resources view... like basically everything is 404... for files that should be public.. I mean I know php files are hidden but... surely if I can't see these js/css files in my browser then my browser won't be able to render them either?
P.S. Also how do I do a shortcut view to the public/ or resources/ folder? Like in Wordpress I used <?php get\_template\_directory\_uri(); ?> or something like that - so I'm just looking for something that is similar with Laravel which is not hard coded.
Thank you
http://127.0.0.1:8000/entradas/1/comprar/1/detalle_ventaEntrada/200000/css/bootstrap.min.css
Here you can see your .css file is trying to load from this url, which is not correct.
Use laravel built in asset() function.
https://laravel.com/docs/master/helpers#method-asset
Which will point to public folder of your application so:
use asset('expamleFolder/bootstrap.js'),
it will look for your bootstrap.js inside public/expamleFolder.
Note: always keep assets in public folder.
Replace this with old code
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ asset('js/jquery.stellar.min.js') }}">
this is solution for that 2 error
Use asset helper
<script src="{{asset('js/main.js')}}"></script>