コード例 #1
0
 public function testProfiler()
 {
     $profiler = new Profiler();
     $profiler->set('foobar', 'hoi');
     $profiler->collect($this->getMock(Request::class), $this->getMock(Response::class));
     $this->assertEquals('hoi', $profiler->get('foobar'));
     $this->assertEquals('webpack', $profiler->getName());
 }
コード例 #2
0
 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'));
 }
コード例 #3
0
 public function testProfiler()
 {
     $profiler = new Profiler();
     $collector = new WebpackDataCollector($profiler);
     $profiler->set('foobar', 'hoi');
     $collector->collect($this->getMockBuilder(Request::class)->getMock(), $this->getMockBuilder(Response::class)->getMock());
     $this->assertEquals('hoi', $collector->get('foobar'));
     $this->assertEquals('webpack', $collector->getName());
 }
コード例 #4
0
 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'));
 }
コード例 #5
0
 /**
  * @return string
  */
 public function compile()
 {
     $this->stopwatch->start('webpack.total');
     $this->stopwatch->start('webpack.prepare');
     // Recompile twig templates where its needed.
     $this->addSplitPoints();
     $this->addResolveConfig();
     // Write the webpack configuration file.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.config.js', $this->generator->getConfiguration());
     $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration());
     $this->stopwatch->start('webpack.compiler');
     $this->process->run();
     $output = $this->process->getOutput() . $this->process->getErrorOutput();
     $this->profiler->set('compiler.executed', true);
     $this->profiler->set('compiler.successful', strpos($output, 'Error:') === false);
     $this->profiler->set('compiler.last_output', $output);
     if ($this->profiler->get('compiler.successful')) {
         $this->tracker->rebuild();
     }
     // Finally, write some logging for later use.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.compiler.log', $output);
     $this->profiler->set('compiler.performance.compiler', $this->stopwatch->stop('webpack.compiler')->getDuration());
     $this->profiler->set('compiler.performance.total', $this->stopwatch->stop('webpack.total')->getDuration());
     return $output;
 }
コード例 #6
0
ファイル: Tracker.php プロジェクト: eljam/webpack-bundle
 private function boot()
 {
     if ($this->booted) {
         return;
     }
     $this->booted = true;
     foreach ($this->finder->findAllTemplates() as $reference) {
         $this->addTemplate($reference);
     }
     foreach (array_keys($this->bundle_paths) as $name) {
         if (false !== ($resolved_path = $this->resolveResourcePath('@' . $name))) {
             $this->aliases['@' . $name] = $resolved_path;
             $this->addPath($resolved_path);
         }
     }
     $this->profiler->set('bundles', $this->aliases);
     $this->profiler->set('templates', $this->templates);
 }
コード例 #7
0
 /**
  * @param  string $id
  * @param  mixed  $default
  * @return string
  */
 public function get($id, $default = false)
 {
     return $this->profiler->get($id, $default);
 }