Skip to content

Commit

Permalink
Merge branch 'release/1.0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 6, 2018
2 parents 69df569 + d0efc96 commit f16b598
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# nystudio107/craft Change Log

## 1.0.9 - 2018.01.06
### Added
* Added a static asset filename-based cache busting `LocalValetDriver.php` for Laravel Valet

## 1.0.8 - 2018.01.01
### Added
* Added a better PurgeCSS pipeline
Expand Down
44 changes: 44 additions & 0 deletions LocalValetDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Implements a static asset filename-based cache busting driver for Craft CMS,
* based on the built-in CraftValetDriver. Place this file in your project root,
* and Valet will pick it up automatically as per the "Local Drivers" section here:
*
* https://laravel.com/docs/5.5/valet
*
* Static asset filename-based cache busting for Craft CMS is discussed here:
*
* https://nystudio107.com/blog/simple-static-asset-versioning
*
* Based on https://gist.github.com/stidges/3d0c0317bf0d36073dd045bbcc742852
*
* @author nystudio107
* @copyright Copyright (c) 2017 nystudio107
* @link https://nystudio107.com/
* @package nystudio107/craft
* @since 1.0.0
* @license MIT
*/

class LocalValetDriver extends CraftValetDriver
{
/**
* @inheritdoc
*/
public function isStaticFile($sitePath, $siteName, $uri)
{
// Try the parent first
$result = parent::isStaticFile($sitePath, $siteName, $uri);
if ($result !== false) {
return $result;
}

// Determine if this is a type we use filename-based cache busting with
if (preg_match('/(.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif|webp)$/i', $uri, $matches)) {
// Rewrite cache busted URIs to their original filename (e.g. jquery.1476809927.js to jquery.js)
return $sitePath.'/'.$this->frontControllerDirectory($sitePath).$matches[1].'.'.$matches[2];
}

return false;
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nystudio107/craft",
"description": "nystudio107 Craft 3 CMS scaffolding project",
"version": "1.0.7",
"version": "1.0.9",
"keywords": [
"craft",
"cms",
Expand Down

0 comments on commit f16b598

Please sign in to comment.