public function LibsassCompiler::compileQueue in SCSS/Less Compiler 8
Compile all queued files.
File
- src/
Plugin/ ScssCompiler/ LibsassCompiler.php, line 119
Class
- LibsassCompiler
- Plugin implementation of the Libsass compiler.
Namespace
Drupal\scss_compiler\Plugin\ScssCompilerCode
public function compileQueue() {
if ($this->queueRun || empty($this->queueList)) {
return;
}
try {
$this->queueRun = TRUE;
$command = self::BASE_COMMAND . ' ' . $this->scriptPath;
$cache_folder = $this->scssCompiler
->getCacheFolder();
$this->fileSystem
->prepareDirectory($cache_folder, FileSystemInterface::CREATE_DIRECTORY);
$files = $this->queueList;
foreach ($files as &$file) {
$css_dir = dirname($file['css_path']);
$this->fileSystem
->prepareDirectory($css_dir, FileSystemInterface::CREATE_DIRECTORY);
}
$import_paths = [
DRUPAL_ROOT,
];
if ($this->scssCompiler
->getAdditionalImportPaths()) {
$import_paths = array_merge($import_paths, $this->scssCompiler
->getAdditionalImportPaths());
}
$data = [
'config' => [
'sourcemaps' => $this->scssCompiler
->getOption('sourcemaps'),
'output_format' => $this->scssCompiler
->getOption('output_format'),
'import_paths' => $import_paths,
],
'files' => $files,
];
$data = json_encode($data);
file_put_contents($cache_folder . '/libsass_temp.json', $data);
$process = new Process($command);
$process
->run(NULL, [
'SCSS_COMPILER_NODE_MODULES_PATH' => $this->scssCompiler
->getOption('node_modules_path'),
'SCSS_COMPILER_DRUPAL_ROOT' => DRUPAL_ROOT,
'SCSS_COMPILER_CACHE_FOLDER' => $this->fileSystem
->realpath($cache_folder),
]);
$this->fileSystem
->delete($cache_folder . '/libsass_temp.json');
if (!$process
->isSuccessful()) {
throw new ProcessFailedException($process);
}
} catch (\Exception $e) {
$this
->messenger()
->addError($e
->getMessage());
}
}