coffeescript - 将 CoffeeScript 与基本的 Yeoman 项目一起使用。

标签 coffeescript gruntjs yeoman

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

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

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

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

最佳答案

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

$ yo angular --coffee

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

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

运行
$ grunt test

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

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

文档还指出,可以使用 yo添加特定的部分,如
  • 角度: Controller
  • 角度:指令
  • 角度:过滤器
  • 角度:路线
  • 角度:服务
  • 角度:装饰器
  • 角度:查看

  • 每个都可以用 --coffee 调用在 CoffeeScript 中切换并获取脚本,例如:
    yo angular:controller user --coffee
    

    关于coffeescript - 将 CoffeeScript 与基本的 Yeoman 项目一起使用。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14943119/

    相关文章:

    javascript - 咕噜声 : creating a zip file with the current date (AAAA-MM-DD)

    yeoman - 你用制表符而不是空格生成

    javascript - 如何在 yeoman 上下文中从 `this.prompt` 获取存储的选项?

    javascript - 多个文件扩展名有什么影响?

    javascript - NodeJS 并发/异步生成 View 以提高性能

    javascript - 提高 RoR 项目的时间响应

    javascript - 如何在不丢失横幅文本的情况下使用 grunt-contrib-less 进行压缩?

    gruntjs - grunt browserify react 需要 jquery

    npm - 运行自耕农角度生成器, karma 依赖错误

    javascript - 运行包含 CoffeeScript 文件导入的 Jest 测试时出现语法错误