Arthur
Arthur

Reputation: 3972

Importing less.js to laravel 5.1

I'm having a hard time getting my project to detect my less.js folder.

I'm using laravel 5.1, and I'm not sure where to put my less.js folder - since for Bootstrap and jQuery I just imported the src from a URL.

I currently have my less.js folder I downloaded under:

resources > assets > less > less.js folder I downloaded

I currently have my styles.less in my views while I try to figure this out.

My app.php head:

<link rel="stylesheet/less" type="text/css" href="styles.less" />
<script src="less.js" type="text/javascript"></script>

I'd appreciate if anyone could quickly let me know where to drop the folder!

Thanks!

edit:

Screenshots:

https://i.sstatic.net/tGo1B.jpg

edit2:

https://i.sstatic.net/PkXeJ.jpg

The error in question:

Status 500 Type Script,

http://localhost:8000/reviewcourse/%3C!DOCTYPE%20html%3E%3Chtml%3E%20%20%20%20%3Chead%3E%20%20%20%20%20%20%20%20%3Cmeta%20charset=

Upvotes: 1

Views: 240

Answers (2)

manix
manix

Reputation: 14747

Only assets published at public/ folder are available. So, you need to drop files there:

public/assets/less/download_folder/less.js

Then load it with:

<script src="{!! url('assets/less/download_folder/less.js') !!}" type="text/javascript"></script>

Another way/solution is to publish assets from /resources to public/ via Elixir:

elixir(function(mix) {
    // location, origin
    mix.copy('assets/less/download_folder/less.js', 'resources/assets/less/folder/less.js');
});

EDIT

I will assume that less.js is inside of public/assets/less/lessjs/dist/less.js. Then, load it as:

<script src="{!! url('assets/less/lessjs/dist/less.js') !!}" type="text/javascript"></script>

Upvotes: 2

yudijohn
yudijohn

Reputation: 1278

use this script at your html head

<script src="{!! asset('less/less.js') !!}" type="text/javascript"></script>

Upvotes: 1

Related Questions