The best Grunt plugin ever.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-code-extract --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-code-extract');
In your project's Gruntfile, add a section named codeExtract
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
codeExtract: {
jsExample1: {
options: {
blocks: [
{start: '/* code-extract-start */', end: '/* code-extract-end */', replace: '"a"'},
{
start : '/* start */', end: '/* end */',
replace: function (srcFilepath, replacedSrcPath, origniSrc,
currentDealedPartialSrc, currentDealedRemainedSrcArray, extractedSrcArray) {
return '//sdf';
}
}
]
},
files : [{
expand : true, flatten: true,
src : ['test/source*.js'], dest: 'tmp/',
replace : function (block, srcFilepath) {
return block.replace === '"a"' ? '"A"' : '//' + srcFilepath;
}, extractDest: 'tmp/extract.json'
}]
}
},
});
Type: Array
Default value:
blocks: [{
start: '/* code-extract-start */',
end : '/* code-extract-end */',
replace: ''
}]
Defines the start and end identifier of the replacement block.
Type: String
Or Function
Default value: ''
Define a replacement string or a custom replacement function.
(Nothing yet)