How to replace ngAnnotate to babel-plugin-angularjs-annotate in grunt task
Asked Answered
G

1

6

I am using angular js (1.6),I have following task in grunt for minification angular modules

ngAnnotate: {
  dist: {
    files: [{
      expand: true,
      cwd: '.tmp/concat/scripts',
      src: '*.js',
      dest: '.tmp/concat/scripts'
    }]
  }
}

But above task not support ES2015 and ES2016 features How to add babel-plugin-angularjs-annotate in grunt task in i.e.grunt file

Glass answered 6/9, 2018 at 4:23 Comment(0)
P
-1

Firstly, install the plugin:

npm install babel-plugin-angularjs-annotate --save-dev

then there are two ways:

  1. follow the readme, add the plugin into .babelrc file:

    { "plugins": ["angularjs-annotate"] }

  2. in grunt.initConfig, set this plugin at babel part, like:

    babel: { options: { sourceMap: true, presets: [@babel/preset-env], plugins: ['angularjs-annotate'] }, files: { expand: true, ... } }

any of them work.

my environment:

  1. grunt-cli v1.3.2
  2. grunt v1.0.3
Paine answered 5/12, 2018 at 20:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.