简体   繁体   English

如何在grunt任务中将ngAnnotate替换为babel-plugin-angularjs-annotate

[英]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 我正在使用angular js(1.6),在grunt中有以下任务来缩小角度模块

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 但是以上任务不支持ES2015和ES2016功能如何在iegrunt文件中的grunt任务中添加babel-plugin-angularjs-annotate

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: 按照自述文件,将插件添加到.babelrc文件中:

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

  2. in grunt.initConfig, set this plugin at babel part, like: 在grunt.initConfig中,将此插件设置为babel部分,例如:

    babel: { options: { sourceMap: true, presets: [@babel/preset-env], plugins: ['angularjs-annotate'] }, files: { expand: true, ... } } babel:{选项:{sourceMap:true,预设:[@ babel / preset-env],插件:['angularjs-annotate']},文件:{expand:true,...}}

any of them work. 他们中的任何一个都可以。

my environment: 我的环境:

  1. grunt-cli v1.3.2 grunt-cli v1.3.2
  2. grunt v1.0.3 咕unt v1.0.3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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