laravel-sass icon indicating copy to clipboard operation
laravel-sass copied to clipboard

[better instalation instructions] I have found a better way to install laravel-sass

Open fcolecumberri opened this issue 6 years ago • 3 comments

after te composer step, instead of messing with public/index.php which is a very bad idea, it's better to make a service provider named SassServiceProvider (I am not sure if service provider were meant to do this, but this works) and there:

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use SassCompiler;

class SassServiceProvider extends ServiceProvider
{
	/**
	 * Bootstrap services.
	 *
	 * @return void
	 */
	public function boot()
	{
		if(config('app.debug') == true){
			SassCompiler::run("../resources/sass/", "css/");
		}
	}

	/**
	 * Register services.
	 *
	 * @return void
	 */
	public function register()
	{
		//
	}
}

also remember to register the service provider in config/app.php

with this, you are sure you will only do stuff when you are not in development, and you are not messing with laravel's core.

the only bad thing about this solution is that SassCompiler::run() first argument needs to have the ../resources/ at the beginning which is not so bad after all.

fcolecumberri avatar May 23 '19 11:05 fcolecumberri

It seems to run, but I get a blank app.css file.

funkytaco avatar Jun 13 '19 04:06 funkytaco

At the end I found out that is better use laravel-mix, you can find out how to use it in https://www.youtube.com/watch?v=UzegdHgNEF4

pd. que mamada que hablemos en ingles

fcolecumberri avatar Jun 13 '19 15:06 fcolecumberri

Hi, yes this repo is really really old (i started this around 2012 i think), please have a look at Laravel Mix or other scss compilers for other frameworks ()they also work without a framework), it'S worth it :)

panique avatar Jun 13 '19 21:06 panique