Skip to content

Commit

Permalink
Use grunt-wp-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
retlehs committed Mar 31, 2014
1 parent b524fb8 commit be14fdb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 13 additions & 17 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
}
}
},
Expand Down Expand Up @@ -144,12 +148,6 @@ module.exports = function(grunt) {
'*.php'
]
}
},
clean: {
dist: [
'assets/css/main.min.*.css',
'assets/js/scripts.min.*.js'
]
}
});

Expand All @@ -165,12 +163,10 @@ module.exports = function(grunt) {
]);
grunt.registerTask('build', [
'jshint',
'clean',
'less:build',
'autoprefixer:build',
'uglify',
'modernizr',
'filerev',
'filerev_assets'
'version'
]);
};
6 changes: 3 additions & 3 deletions lib/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit be14fdb

Please sign in to comment.