Hostnet\Component\Webpack\Asset\CacheGuard::rebuild PHP Method

rebuild() public method

Rebuild the cache, check to see if it's still valid and rebuild if it's outdated.
public rebuild ( )
    public function rebuild()
    {
        if ($this->tracker->isOutdated()) {
            $this->logger->info('[Webpack 1/2]: Compiling assets.');
            $output = $this->compiler->compile();
            $this->logger->debug($output);
            $this->logger->info('[Webpack 2/2]: Dumping assets.');
            $this->dumper->dump();
        } else {
            $this->logger->info('[Webpack]: Cache still up-to-date.');
        }
    }

Usage Example

 /**
  * On Request received check the validity of the webpack cache.
  *
  * @param GetResponseEvent $event the response to send to te browser, we don't we only ensure the cache is there.
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $this->guard->rebuild();
 }
All Usage Examples Of Hostnet\Component\Webpack\Asset\CacheGuard::rebuild