Minify ASP.NET Razor Views (.cshtml).
npm install grunt-minify-cshtml~0.4.5
shell
npm install grunt-minify-cshtml --save-dev
`
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js
grunt.loadNpmTasks('grunt-minify-cshtml');
`
The "minify_cshtml" task
$3
In your project's Gruntfile, add a section named minify_cshtml to the data object passed into grunt.initConfig().
`js
grunt.initConfig({
minify_cshtml: {
options: {
comments: true, // strip comments
razorComments: true, // strip razor comments @ @
whitespace: true, // strip whitespaces inbetween markup ><
linebreaks: true, // strip double linebreaks \n\n
dir: 'test', // base directory usually "Views"
filetype: '.cshtml', // filetypes to be replaced
test: true // test mode if false it will overwrite the files
}
},
});
`
$3
#### Default Options
In this example, the default options are used to do convert all cshtml markup pages.
`js
grunt.initConfig({
minify_cshtml: {
options: {
comments: true,
razorComments: true,
whitespace: true,
linebreaks: true,
dir: 'Views',
filetype: '.cshtml',
test: false
}
},
});
``