From be14fdb69c7f534ebbb9efab7ebe5545a4a1895a Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 30 Mar 2014 23:01:59 -0500 Subject: [PATCH] Use grunt-wp-assets --- .gitignore | 2 +- Gruntfile.js | 30 +++++++++++++----------------- lib/scripts.php | 6 +++--- package.json | 4 +--- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 7c08aa5..95cee23 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ assets/css/main.css.map assets/css/*main*.css assets/js/*scripts*.js assets/js/vendor/modernizr.min.js -assets-manifest.json +assets/manifest.json diff --git a/Gruntfile.js b/Gruntfile.js index 7983f22..fb7098e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -105,15 +105,19 @@ module.exports = function(grunt) { parseFiles: true } }, - filerev: { - assets: { - src: ['assets/css/main.min.css', 'assets/js/scripts.min.js'] - } - }, - filerev_assets: { - assets: { + version: { + default: { options: { - dest: 'assets-manifest.json' + format: true, + length: 32, + manifest: 'assets/manifest.json', + querystring: { + style: 'roots_css', + script: 'roots_js' + } + }, + files: { + 'lib/scripts.php': 'assets/{css,js}/{main,scripts}.min.{css,js}' } } }, @@ -144,12 +148,6 @@ module.exports = function(grunt) { '*.php' ] } - }, - clean: { - dist: [ - 'assets/css/main.min.*.css', - 'assets/js/scripts.min.*.js' - ] } }); @@ -165,12 +163,10 @@ module.exports = function(grunt) { ]); grunt.registerTask('build', [ 'jshint', - 'clean', 'less:build', 'autoprefixer:build', 'uglify', 'modernizr', - 'filerev', - 'filerev_assets' + 'version' ]); }; diff --git a/lib/scripts.php b/lib/scripts.php index a97c4e3..bbc8665 100644 --- a/lib/scripts.php +++ b/lib/scripts.php @@ -20,11 +20,11 @@ function roots_scripts() { * Read the asset names from assets-manifest.json */ if (!(WP_ENV === 'development')) { - $get_assets = file_get_contents(get_template_directory_uri() . '/assets-manifest.json'); + $get_assets = file_get_contents(get_template_directory_uri() . '/assets/manifest.json'); $assets = json_decode($get_assets, true); $assets = array( - 'css' => '/' . $assets['assets/css/main.min.css'], - 'js' => '/' . $assets['assets/js/scripts.min.js'], + 'css' => '/assets/css/main.min.css' . '?' . $assets['assets/css/main.min.css']['hash'], + 'js' => '/assets/js/scripts.min.js' . '?' . $assets['assets/js/scripts.min.js']['hash'], 'modernizr' => '/assets/js/vendor/modernizr.min.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' ); diff --git a/package.json b/package.json index 3c0cdc1..34cf391 100644 --- a/package.json +++ b/package.json @@ -26,15 +26,13 @@ "bower": "~1.2.8", "grunt": "~0.4.2", "grunt-autoprefixer": "~0.7.2", - "grunt-filerev": "~0.2.1", - "grunt-filerev-assets": "~0.3.0", - "grunt-contrib-clean": "~0.5.0", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-jshint": "~0.6.4", "grunt-contrib-less": "~0.8.1", "grunt-contrib-uglify": "~0.2.4", "grunt-contrib-watch": "~0.5.3", "grunt-modernizr": "~0.5.1", + "grunt-wp-assets": "git://github.com/roots/grunt-wp-assets.git#master", "load-grunt-tasks": "~0.3.0", "time-grunt": "~0.3.1" }