简体   繁体   中英

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

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 iegrunt file

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM