Added cache busters for Webpack scripts.

This commit is contained in:
Peter Deltchev 2016-02-16 03:54:48 -08:00
parent 4f6f64a3c0
commit 840e233acf
3 changed files with 24 additions and 13 deletions

View file

@ -20,6 +20,28 @@
class Assets
{
public static function scriptIncludes(string $area) {
$scriptTags = '';
if ('app' === $area) {
$scripts = ['app.js', 'templates.js'];
} elseif ('embed' === $area) {
$scripts = ['embed.js'];
} else {
throw new InvalidArgumentException('A valid app area must be specified!');
}
foreach ($scripts as $filename) {
$scriptTags .= "<script src='/build/scripts/{$filename}?" . filemtime(public_path("build/scripts/{$filename}")) . "'></script>";
}
if (Config::get("app.debug")) {
$scriptTags .= '<script src="http://localhost:61999/webpack-dev-server.js"></script>';
}
return $scriptTags;
}
public static function styleIncludes($area = 'app')
{
if (!Config::get("app.debug")) {

View file

@ -158,13 +158,7 @@
</script>
@endif
@if (Config::get("app.debug"))
<script src="http://localhost:61999/build/scripts/app.js"></script>
<script src="http://localhost:61999/webpack-dev-server.js"></script>
@else
<script src="/build/scripts/app.js"></script>
<script src="/build/scripts/templates.js"></script>
@endif
{!! Assets::scriptIncludes('app') !!}
@yield('app_scripts')

View file

@ -62,12 +62,7 @@
</div>
@endif
@if (Config::get("app.debug"))
<script src="http://localhost:61999/build/scripts/embed.js"></script>
<script src="http://localhost:61999/webpack-dev-server.js"></script>
@else
<script src="/build/scripts/embed.js"></script>
@endif
{!! Assets::scriptIncludes('embed') !!}
@if(config('ponyfm.google_analytics_id'))
<script type="text/javascript">