2016-08-25 1 views
1

SS에서는 결합 된 파일을 사용하여 웹 사이트를 더 빠르게 실행할 수 있습니다. 그러나 일부 파일이 업데이트되고 파일이 결합 된 파일로 새로 고쳐지지 않을 때 문제가 발생했습니다. 결합 된 파일을 삭제하고 캐시를 플러시하여 파일을 다시 만들어야합니다 ... CSS 파일이 변경 될 때 결합 된 파일 생성을 다시 실행하는 기능이 있습니까? 파일 날짜를 확인 하시겠습니까?Silverstripe 요구 사항 결합 파일 CSS와 JS

예 :

$stylesheets = array(
    "$themeDir/css/HomePage.css", 
    "$themeDir/css/Page.css", 
); 

Requirements::combine_files('combinedfiles.css', $stylesheets'); 

답변

2

파일이 dev 모드로 결합되지 않습니다. 따라서 개발 과정에서 파일이 많이 바뀌면 개발자 모드에서 사이트를 실행하십시오.

또한 모든 파일을 정상적으로 받아야합니다. 변경된 코드 :

$stylesheets = [ 
    $this->themeDir() . '/css/HomePage.css', 
    $this->themeDir() . '/css/Page.css' 
]; 

// require the css stylesheet normally 
foreach ($stylesheets as $stylesheet) { 
    Requirements::css($stylesheet); 
} 

// combine the files. In dev-mode, this has no effect 
Requirements::combine_files('combinedfiles.css', $stylesheets); 

당신의 웹 사이트가 live 모드에있는 개별 파일이 결합 된 파일로 대체됩니다.

+0

매우 간단합니다. – StefGuev

+0

약간의 메모, 조건을 추가해야합니다 -> if (isDev) {do nothing} else {combined_files} 라이브 모드 이후에 combined_files를 업데이트하기 위해 플러시하기 – StefGuev