Last active
August 29, 2015 14:16
-
-
Save DanielHudson/a94e40e2e84001366fdd to your computer and use it in GitHub Desktop.
cdnify for laravel/elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists('cdnify')) | |
{ | |
/** | |
* Adds a CDN to a path when a specified environment is active. | |
* | |
* @param string $path | |
* @param array $environment | |
* @param boole $elixir | |
* | |
* @return string|false | |
*/ | |
function cdnify($path, $environment = ['production'], $elixir = true) | |
{ | |
$path = $path ?: false; | |
if($path === false) | |
{ | |
return false; | |
} | |
if($elixir === true) | |
{ | |
$path = elixir($path); | |
} | |
if(in_array(env('APP_ENV'), $environment)) | |
{ | |
$path = config('cdn.cloudfront') . $path; | |
} | |
return $path; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"files": ["app/Http/helpers.php"],
<link href="{{ cdnify('css/app.css') }}" rel="stylesheet">