gulp-wp-rev plugin for gulp
Revisioning CSS/JS appending a hash in you assets of wordpress theme.
styles.css?ver=1
→ styles.css?ver=bd0622b828f9346876088cd617566fa5
First, install gulp-wp-rev
as a development dependency:
npm install --save-dev gulp-wp-rev
Then, add it to your gulpfile.js
:
var wpRev = require('gulp-wp-rev');
gulp.task('rev', function() {
gulp.src('./wp-content/themes/raulghm-theme/lib/scripts.php')
.pipe(wpRev([
{
handle: 'my-styles',
file: './style.css',
type: 'css'
},
{
handle: 'vendor-scripts',
file: './vendor.js',
type: 'js'
},
{
handle: 'my-scripts',
file: './scripts.js',
type: 'js'
},
]))
.pipe(gulp.dest('./wp-content/themes/raulghm-theme/lib'));
});
Type: Array
of Object
s.
Each object describes a resource and has three attributes:
Type: String
Name used as the handle in WordPress
Type: String
Name of the file source.
Type: String
Type of resource, either js
or css
.
MIT © raulghm