Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap compilation takes so much time #661

Open
chetansharma10 opened this issue Sep 21, 2023 · 0 comments
Open

Bootstrap compilation takes so much time #661

chetansharma10 opened this issue Sep 21, 2023 · 0 comments

Comments

@chetansharma10
Copy link

chetansharma10 commented Sep 21, 2023

See this code
Why it takes more than 10 sec to compile,If it is not a right way please tell?

function compile(){
	  $cacheOptions = [
		  'cacheDir' => __DIR__.'/assets/sass-cache',
		  'prefix' => 'scssphp_',
		  'forceRefresh' =>false
	  ];
	
	try{
		$compiler = new Compiler($cacheOptions);

		// Get bootstrap SASS Input file path
		$input_path = __DIR__ . '/vendor/twbs/bootstrap/scss/bootstrap.scss';
		
		// Set Bootstrap CSS Output file path
		$output_path = __DIR__ . '/assets/css/bootstrap.css';
		
		// Get Input File Content
		$input_content = file_get_contents($input_path);
		
		// Set SASS Imports Directory
		$imports_dir_path  = __DIR__ . '/vendor/twbs/bootstrap/scss/';
		
		//  Set SCSS Imports Directory Path
		$compiler->setImportPaths($imports_dir_path);
		
		// Set Variables
		$variables = [
			'$primary' => "#110978",
		];
		
		// Replace Bootstrap Variables with Customizer Variables
		$compiler->replaceVariables($variables);

		// Get Compiled CSS
		$css_string =  $compiler->compileString($input_content);

		file_put_contents(__DIR__."/assets/bootstrap/bootstrap.min.css",$css_string->getCss());
	}
	catch(\Exception $e){
		console_log("Exception:".$e);
	}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant