【问题标题】:Yeoman/gruntjs angularjs and directives with html files in the folderYeoman/gruntjs angularjs 和文件夹中带有 html 文件的指令
【发布时间】:2015-07-10 17:22:56
【问题描述】:

我使用yeoman 作为管理应用程序的工具。由于我有很多指令,我没有使用yeoman 生成指令的标准方式,因此scripts/directive/name.js 用于代码,views/template_directive.html 用于模板。

我改为这样做: scripts/directive/my-directive 和里面我有 jshtml 文件。 here a screenshot

现在,当我 serve 一切正常时,当我运行 build 时,问题就出现了。指令的jsvendor.js 结尾,但html 页面仍指向scripts/directive/my-directive/template_directive.html,这不是dist 的一部分。

我应该(可能,如果有比欢迎更好的选择)做的是:

  • 复制视图文件夹中的html
  • 更改指令js中的引用

  • 找到一种方法将 html 文件也放在 dist 的同一文件夹中(重新创建所有 /directives/<directive>/<template>.html

问题是:

  • 什么是“正确”的解决方案
  • 在 gruntjs 中更改以使其正常工作的命令是什么。

【问题讨论】:

    标签: angularjs gruntjs yeoman grunt-contrib-copy


    【解决方案1】:

    我确实喜欢这个(不确定它是否“正确”但有效)

    将此添加到copy 部分

    ..
    {
     expand: true,
     dot: true,
     cwd: '<%= yeoman.app %>/scripts/directives',
     src: ['*/*.html'],
     dest:'<%= yeoman.dist %>/scripts/directives'
    }
    ..
    

    将此添加到minhtml conf

    files: [{
       ...
       src: [..,'scripts/directives/*/*.html'],
       ...
    }]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-10
      相关资源
      最近更新 更多