Grunt task to merge files by marking
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-marking-merge --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-marking-merge');
In your project's Gruntfile, add a section named marking_merge
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
marking_merge: {
default: {
files : [
{
src : 'Namespace.js', //The file containing marking string
dest : 'merged.js' //The path of the merged file
}
]
},
},
});
Type: String
Default value: /*<
A string value that is used to mark marking start.
Type: String
Default value: >*/
A string value that is used to mark the marking end.
In this example, The two files merged into a third file by marking.
grunt.initConfig({
marking_merge: {
options: {},
files: [{
src : 'Namespace.js',
dest : 'build/Namespace.js'
}]
}
});
The Namespace.js code:
var Namespace = (function (Namespace) {
// The marking of need to merge
/*< Size.js >*/
/*< Pixel.js >*/
Namespace.Size = Size;
Namespace.Pixel = Pixel;
})(Namespace || {});
In this example, custom options are used to do something else with whatever else. So if the testing
file has the content Testing
and the 123
file had the content 1 2 3
, the generated result in this case would be Testing: 1 2 3 !!!
grunt.initConfig({
marking_merge: {
options: {
startSymbol: '/*--',
punctuation: '--*/'
},
files: [{
src : 'Namespace.js',
dest : 'build/Namespace.js'
}]
},
});
var Namespace = (function (Namespace) {
// The marking of need to merge
/*-- Size.js --*/
/*--Pixel.js--*/
Namespace.Size = Size;
Namespace.Pixel = Pixel;
})(Namespace || {});