带有ngAnnotate的目标文件夹

时间:2017-03-22 12:58:20

标签: angularjs gruntjs ng-annotate

我的项目文件夹如下所示:

project
__src
____main
______webapp
________WEB-INF
__________app
____________components
            //Angular files here.

我使用此配置进行了ng-annotate的grunt任务:

 ngAnnotate: {
      options: {
          singleQuotes: true
      },
      app: {
          files: [{
                expand: true,
                src: 'src/main/webapp/WEB-INF/app/components/**/*.js',
                ext: '.safe.js',
                dest: 'src/main/webapp/WEB-INF/app/min',
                extDot: 'last'
          }]
      }
  },

我想要文件夹“src / main / webapp / WEB-INF / app / min”中的所有带注释文件,所有这些文件都可以使用。

我的问题是,grunt任务创建了整个路径到“min”文件夹里面的文件我想:

我在src / main / webapp / WEB-INF / app / components / module / module.js中有一个文件 我想在src / main / webapp / WEB-INF / app / min / module.safe.js中找到该文件

但我得到的是src / main / webapp / WEB-INF / app / min / src / main / webapp / WEB-INF / app / components / module / module.safe.js

如何在不创建整个路径的情况下完成此任务?

1 个答案:

答案 0 :(得分:0)

我终于用cwd命令解决了它,所以。

ngAnnotate: {
      options: {
          singleQuotes: true
      },
      app: {
          files: [{
                expand: true,
                cwd: 'src/main/webapp/WEB-INF/app/components/',
                src: ['**/*.js', '**/*.js', '!**/min/*', '!**/min-app/*'],
                ext: '.safe.js',
                dest: 'src/main/webapp/WEB-INF/app/min',
                extDot: 'last'
          }]
      }
  },

cwd是到源路径的路由。 Src只会使用javascript名称。