Created
April 29, 2019 02:47
-
-
Save mfyz/2e37fe66a66b2e012bcb597d938aaf58 to your computer and use it in GitHub Desktop.
Grunt Replace Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (grunt) { | |
// measures the time each task takes | |
require('time-grunt')(grunt); | |
grunt.loadNpmTasks('grunt-replace'); | |
grunt.initConfig({ | |
// Store your Package file so you can reference its specific data whenever necessary | |
pkg: grunt.file.readJSON('package.json'), | |
replace: { | |
asset_version: { | |
options: { | |
// usePrefix: false, | |
patterns: [ | |
{ | |
match: /define\('CSS_VERSION\', '([0-9]*)'\)/, | |
replacement: function(){ | |
return "define('CSS_VERSION', '" + (parseInt(arguments[1]) + 1) + "')"; | |
} | |
}, | |
{ | |
match: /define\('JS_VERSION\', '([0-9]*)'\)/, | |
replacement: function(){ | |
return "define('JS_VERSION', '" + (parseInt(arguments[1]) + 1) + "')"; | |
} | |
} | |
] | |
}, | |
files: [ | |
{ expand: true, flatten: true, src: ['config.php'], dest: './' } | |
] | |
} | |
} | |
}); | |
grunt.registerTask('default', ['replace']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment