public function testRequestCompile() { $this->tracker->expects($this->once())->method('isOutdated')->willReturn(true); $this->compiler->expects($this->once())->method('compile'); $this->dumper->expects($this->once())->method('dump'); $this->event->expects($this->once())->method('isMasterRequest')->willReturn(true); (new RequestListener($this->tracker, $this->compiler, $this->dumper))->onRequest($this->event); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->logger->info('[WEBPACK]: Compiling assets...'); $this->compiler->compile(); $this->logger->info('[WEBPACK]: Dumping assets...'); $this->dumper->dump(new Filesystem()); $this->logger->debug($this->profiler->get('compiler.last_output')); }
/** * @param GetResponseEvent $event */ public function onRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if ($this->tracker->isOutdated()) { $this->compiler->compile(); } $this->dumper->dump(new Filesystem()); }
protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Webpack [1/2]: Compiling Assets'); $this->logger->info('[WEBPACK]: Compiling assets...'); $this->compiler->compile(); $output->writeln('Webpack [2/2]: Dumping Assets'); $this->logger->info('[WEBPACK]: Dumping assets...'); $this->dumper->dump(); $message = $this->profiler->get('compiler.successful') ? sprintf('<info>Compilation done in %d ms.</info>', $this->profiler->get('compiler.performance.total')) : sprintf('<error>%s</error>', $this->profiler->get('compiler.last_output')); $output->writeln($message); $this->logger->debug($this->profiler->get('compiler.last_output')); }
/** * Rebuild the cache, check to see if it's still valid and rebuild if it's outdated. */ 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.'); } }
/** * Returns an array containing a 'js' and 'css' key that refer to the path of the compiled asset from a browser * perspective. * * @param string $asset * @return array */ public function webpackAsset($asset) { $asset_id = $this->public_path . '/' . Compiler::getAliasId($asset); $full_asset_path = $this->web_dir . '/' . $asset_id; return ['js' => file_exists($full_asset_path . '.js') ? $asset_id . '.js?' . filemtime($full_asset_path . '.js') : false, 'css' => file_exists($full_asset_path . '.css') ? $asset_id . '.css?' . filemtime($full_asset_path . '.css') : false]; }
/** * Returns an array containing a 'js' and 'css' key that refer to the path of the compiled asset from a browser * perspective. * * @param string $asset * @return array */ public function webpackAsset($asset) { $asset_id = rtrim($this->public_path, '/') . '/' . Compiler::getAliasId($asset); $document_root = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : ''; return ['js' => file_exists($document_root . '/' . $asset_id . '.js') ? $asset_id . '.js' : false, 'css' => file_exists($document_root . '/' . $asset_id . '.css') ? $asset_id . '.css' : false]; }