Remove comments from code
npm install grunt-stripcomments=>0.4.0
shell
npm install grunt-stripcomments --save-dev
`
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js
grunt.loadNpmTasks('grunt-stripcomments');
`
The "comments" task
$3
In your project's Gruntfile, add a section named comments to the data object passed into grunt.initConfig().
`js
grunt.initConfig({
comments: {
your_target: {
// Target-specific file lists and/or options go here.
options: {
singleline: true,
multiline: true,
keepSpecialComments: false
},
src: [ 'src/*.js'] // files to remove comments from
},
},
});
`
$3
#### options.keepSpecialComments
Type: Boolean
Default value: true
Determines whether or not to remove comments starting with /*!.
Note: NO special comments should be removed if the code is not yours. Special comments are used as attribution and you should consult with the authors before even considering stripping them from the source.
#### options.singleline
Type: Boolean
Default value: true
Determines whether or not to remove single line comments
#### options.multiline
Type: Boolean
Default value: true
Determines whether or not to remove multi line comments
$3
`js
grunt.initConfig({
comments: {
js: {
options: {
singleline: true,
multiline: false
},
src: [ 'src/*.js' ]
},
php: {
options: {
singleline: true,
multiline: true
},
src: [ 'lib/*.php' ]
}
},
});
``