This article describes how to replace the deprecated ngmin with ng-annotate.
ngmin used to be a popular AngularJS application pre-minifier. Though it is now deprecated.
message: npm WARN deprecated ngmin@0.5.0: use ng-annotate instead
cause: ngmin is no longer maintained, you should use ng-annotate instead.
solution: Migrate from ngmin to ng-annotate:
ng-annotate -a
is similar tongmin
(use stdin and stdout).ng-annotate -a in.js -o out.js
is similar tongmin in.js out.js
.
– Installation:
1 |
$ npm install -g ng-annotate |
Grunt users can migrate easily by installing grunt-ng-annotate and replacing
ngmin
with ngAnnotate
in their Gruntfile.
– Install grunt-ng-annotate:
Start a shell at the folder where gruntfile.js is located and execute:
1 |
$ npm install grunt-ng-annotate --save-dev |
– Modify your gruntfile.js: replace any occurrence of ngmin
in ngAnnotate
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
//Changes angular code to minification safe angular code ngAnnotate: { dist: { files: [ { expand: true, cwd: '.tmp/concat/scripts', src: '*.js', dest: '.tmp/concat/scripts' } ] } } ... grunt.registerTask('build', [ 'clean:dist', 'useminPrepare', 'imagemin', 'concat', 'ngAnnotate:dist', 'copy:dist', 'cssmin', 'uglify', 'rev', 'usemin', 'clean:tmp' ]); |
Done!