Example #1
0
 public function preStaticServe(StaticServer $server)
 {
     // If file was a package file, don't do anything
     if ($this->is_package) {
         return;
     }
     // If the type isn't css we don't touch it
     if ($server->getType() != 'css') {
         return;
     }
     $path = $server->getPath();
     $cache_path = $this->cache . '.' . preg_replace('#\\W#', '', $path);
     // Compile and cache CSS file.
     $cache = new FileCache($cache_path, $path);
     $cache->setExtension('css');
     if ($cache->isOutDated() || $this->force_update) {
         $contents = file_get_contents($path);
         $compiler = new CSSCompiler($contents);
         $updated = $compiler->compile();
         $cache->update($updated);
     }
     // Change the path to be the cached file instead
     $server->setPath($cache->getFile());
 }