Use gulp-rev for versioning CSS and JS
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,9 +1,9 @@
|
||||
# Include your project-specific ignores in this file
|
||||
# Read about how to use .gitignore: https://help.github.com/articles/ignoring-files
|
||||
node_modules
|
||||
assets/vendor/*
|
||||
assets/vendor
|
||||
assets/css/main.css.map
|
||||
assets/css/*main*.css
|
||||
assets/js/*scripts*.js
|
||||
assets/js/vendor/modernizr.min.js
|
||||
assets/manifest.json
|
||||
assets/rev-manifest.json
|
||||
|
||||
17
gulpfile.js
17
gulpfile.js
@@ -9,11 +9,9 @@ var gulp = require('gulp'),
|
||||
uglify = require('gulp-uglify'),
|
||||
livereload = require('gulp-livereload'),
|
||||
stylish = require('jshint-stylish'),
|
||||
rev = require('gulp-rev');
|
||||
modernizr = require('gulp-modernizr');
|
||||
|
||||
// add all the gruntfile tasks to gulp
|
||||
require('gulp-grunt')(gulp);
|
||||
|
||||
var paths = {
|
||||
scripts: [
|
||||
'assets/vendor/bootstrap/js/transition.js',
|
||||
@@ -35,7 +33,7 @@ var paths = {
|
||||
'gulpfile.js',
|
||||
'assets/js/*.js',
|
||||
'!assets/js/scripts.js',
|
||||
'!assets/**/*.min.*'
|
||||
'!assets/**/*.min-*'
|
||||
],
|
||||
less: 'assets/less/main.less'
|
||||
};
|
||||
@@ -44,10 +42,9 @@ var destination = {
|
||||
css: 'assets/css',
|
||||
scripts: 'assets/js',
|
||||
modernizr: 'assets/vendor/modernizr',
|
||||
vendor: 'assets/vendor'
|
||||
vendor: 'assets/js/vendor'
|
||||
};
|
||||
|
||||
|
||||
gulp.task('less', function () {
|
||||
return gulp.src(paths.less)
|
||||
.pipe(sourcemaps.init())
|
||||
@@ -91,7 +88,11 @@ gulp.task('modernizr', function() {
|
||||
});
|
||||
|
||||
gulp.task('version', function() {
|
||||
gulp.run('grunt-version');
|
||||
return gulp.src(['assets/css/main.min.css', 'assets/js/scripts.min.js'], { base: 'assets' })
|
||||
.pipe(rev())
|
||||
.pipe(gulp.dest('assets'))
|
||||
.pipe(rev.manifest())
|
||||
.pipe(gulp.dest('assets'));
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
@@ -107,4 +108,4 @@ gulp.task('watch', function() {
|
||||
|
||||
gulp.task('default', ['less', 'jshint', 'js', 'modernizr']);
|
||||
gulp.task('dev', ['default']);
|
||||
gulp.task('build', ['less', 'jshint', 'js', 'modernizr', 'version']);
|
||||
gulp.task('build', ['less', 'jshint', 'js', 'modernizr', 'version']);
|
||||
|
||||
@@ -27,11 +27,11 @@ function roots_scripts() {
|
||||
'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js'
|
||||
);
|
||||
} else {
|
||||
$get_assets = file_get_contents(get_template_directory() . '/assets/manifest.json');
|
||||
$get_assets = file_get_contents(get_template_directory() . '/assets/rev-manifest.json');
|
||||
$assets = json_decode($get_assets, true);
|
||||
$assets = array(
|
||||
'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'],
|
||||
'css' => '/assets/' . $assets[get_template_directory() . '/assets/css/main.min.css'],
|
||||
'js' => '/assets/' . $assets[get_template_directory() . '/assets/js/scripts.min.js'],
|
||||
'modernizr' => '/assets/js/vendor/modernizr.min.js',
|
||||
'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'
|
||||
);
|
||||
@@ -79,7 +79,7 @@ add_action('wp_head', 'roots_jquery_local_fallback');
|
||||
|
||||
/**
|
||||
* Google Analytics snippet from HTML5 Boilerplate
|
||||
*
|
||||
*
|
||||
* Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM
|
||||
*/
|
||||
function roots_google_analytics() { ?>
|
||||
|
||||
Reference in New Issue
Block a user