grunt-nghtml-uglify

Grunt task to uglify HTML files mixed with AngularJS directives to make them valid HTML5

Usage no npm install needed!

<script type="module">
  import gruntNghtmlUglify from 'https://cdn.skypack.dev/grunt-nghtml-uglify';
</script>

README

grunt-nghtml-uglify Build Status

Grunt task for nghtml-uglify

Getting Started

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, install this plugin with this command:

$ npm install --save-dev grunt-nghtml-uglify

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-nghtml-uglify');

Tip: the grunt-nghtml-uglify module makes it possible to keep the source code beatiful with custom angular directives, without worrying about HTML5 validation and old IE browser issues.

Documentation

See the grunt docs on how to configure tasks and more advanced usage.

Example with custom config and rules

 grunt.initConfig({
     nghtmlUglify: {
         options: {
             directives: 'configs/directives.json'
         },
         dev: {
             files: [{
                 expand: true,
                 cwd: 'tests/',
                 src: ['*.html'],
                 dest: 'tmp/',
                 ext: '.ng.html',
                 extDot: 'first'
             }]
         }
     }
});

grunt.loadNpmTasks('grunt-nghtml-uglify');
grunt.registerTask('default', ['nghtmlUglify']);

Examples

Please see Gruntfile as an example usage

Options

prefix

Type: String Default: 'data-'

This config exist in case of a possible XHTML support in future release, you may safelyskip it if you are already using HTML5.

directives

Type: String Default: ''

  • Note that you should provide one, see an example

Path to a json file which contains the angular and custom directives that are being used. In future, we may parse javascript and get the directives automatically. Yet for the time being adduming you use grunt-html-validation, you will know which directives to add to the directives.json

License

MIT © Ahmet Yeşil