【问题标题】:Using coffeescript with basic Yeoman project.将咖啡脚本与基本的 Yeoman 项目一起使用。
【发布时间】:2013-02-03 06:51:55
【问题描述】:

我使用Yeoman 使用yo webapp 生成器命令制作了一个快速的项目框架。在生成的 Gruntfile 中,我看到它已设置为编译 CoffeeScript,但它似乎只是将已编译的文件粘贴在 tmp 文件夹中。

coffee: {
    dist: {
        files: {
           '.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
        }
    },
},

这些如何在开发过程中包含在项目中。我没有使用 RequireJS。

yeoman 文档不清楚如何使用 coffeescript。他们只提到它会自动编译。

【问题讨论】:

    标签: coffeescript gruntjs yeoman


    【解决方案1】:

    我刚刚在 github 存储库中发现了一个引用此问题的问题。 https://github.com/yeoman/generator-webapp/issues/12

    它提供了一个临时解决方案:https://github.com/yeoman/generator-webapp/issues/12#issuecomment-13731929

    【讨论】:

      【解决方案2】:

      使用 yeomen 1.0.0-rc1.4。我用:

      $ yo angular --coffee
      

      生成的项目在 CoffeeScript 中有控制器和应用程序脚本。

      grunt 配置文件保留在 js 中(这不是真正的问题)。

      跑步

      $ grunt test
      

      运行测试,一切似乎都很好。

      $ grunt server
      

      也在做人们期望的事情(构建应用程序,测试它,启动服务器,在网络浏览器中打开应用程序并开始观察更改,所以如果我更改咖啡脚本文件,它会很快反映在网络浏览器中。

      文档还指出,可以使用 yo 添加特定的部分,例如

      • 角度:控制器
      • 角度:指令
      • 角度:过滤器
      • 角度:路线
      • 角度:服务
      • 角度:装饰器
      • 角度:视图

      每个都可以通过--coffee 开关调用并在 CoffeeScript 中获取脚本,例如:

      yo angular:controller user --coffee
      

      【讨论】:

        猜你喜欢
        • 2016-01-05
        • 1970-01-01
        • 2016-02-26
        • 2011-11-08
        • 1970-01-01
        • 1970-01-01
        • 2015-06-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多