728x90

sass 로 스타일 작업을 많이 하는데 php 에서는 바로 link 를 할수가 없다. css 파일로 컴파일 후 link 해야 하는데 php 명령어로도 컴파일이 가능하다. 아래 명령어로 해당 경로에 css 파일을 생성하게끔 한다면 php 코드에서도 sass 파일을 사용 할수 있다. 

<?php
// SASS 파일의 경로
$sass_file = 'styles.scss';

// 컴파일된 CSS 파일의 경로
$css_file = 'styles.css';

// SASS 파일을 CSS로 컴파일하는 명령
$command = "sass $sass_file $css_file";

// 명령 실행
$output = shell_exec($command);

// 결과 출력
echo $output;
?>
728x90

+ Recent posts