【问题标题】:How to replace ngAnnotate to babel-plugin-angularjs-annotate in grunt task如何在 grunt 任务中将 ngAnnotate 替换为 babel-plugin-angularjs-annotate
【发布时间】:2019-02-11 06:27:00
【问题描述】:

我正在使用 Angular js (1.6),我在 grunt 中有以下任务以缩小 Angular 模块

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

但上述任务不支持 ES2015 和 ES2016 功能 如何在grunt任务中添加babel-plugin-angularjs-annotate,即grunt文件

【问题讨论】:

    标签: angularjs gruntjs bundling-and-minification grunt-contrib-uglify gruntfile


    【解决方案1】:

    首先,安装插件:

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

    那么有两种方法:

    1. 按照自述文件,将插件添加到 .babelrc 文件中:

      { “插件”:[“angularjs-annotate”] }

    2. 在 grunt.initConfig 中,在 babel 部分设置这个插件,比如:

      通天塔:{ 选项: { 源地图:真, 预设:[@babel/preset-env], 插件:['angularjs-annotate'] }, 文件:{ 展开:真, ... } }

    其中任何一个都有效。

    我的环境:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-23
      • 2021-03-08
      • 1970-01-01
      • 2014-09-07
      • 2016-03-27
      • 2013-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多