protected function bundle($_filenames, $_ext = 'js') { $_filenames = !is_array($_filenames) ? array($_filenames) : $_filenames; $filename = 'wasabi' . md5(implode('|', $_filenames)) . $this->_getFileLastModifiedTimesIndentifier($_filenames); $ext = strtolower(trim($_ext)); $filename = $filename . '.' . $ext; $bundle_dir_base_path = $this->BASE_BUNDLES_DIR; $content = '/*' . "\n * " . implode("\n * ", $_filenames) . "\n" . ' */' . "\n"; $BUNDLES_DIR = App\Files::makeDirIfNotExists($this->BUNDLES_DIR); if (App\Files::exists($BUNDLES_DIR . '/' . $filename)) { return $bundle_dir_base_path . '/' . $filename; } foreach ($_filenames as $f) { $f = preg_replace('/\\?.+$/', '', $f); // Remove query string $content .= "\n /*----------- " . $f . " ------------*/ \n"; if ($ext === 'js') { // See: https://github.com/tedious/JShrink $content .= JShrink\Minifier::minify(App\Files::get(rtrim($f, '/'))); } } App\Files::makeFile($BUNDLES_DIR . '/' . $filename, $content); return $bundle_dir_base_path . '/' . $filename; }