Returns the alias id for the given path.
public static getAliasId ( string $path ) : string | ||
$path | string | |
return | string |
/** * 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]; }