【问题标题】:Compile to `.js` maintaining the same folder structure编译为 `.js` 保持相同的文件夹结构
【发布时间】:2013-03-30 17:09:38
【问题描述】:

在我的应用程序(Asp.net mvc)中,我有以下文件夹结构:

Scripts 文件夹包含所有 .js.coffee 文件。在文件夹Controllers 中,每个控制器都有一个文件夹。

我需要每当.coffee 文件发生更改时,都会在同一个文件夹中创建一个具有相同名称的新文件.js

module.exports = (grunt) -> 
    # Configurações
    grunt.initConfig
        coffee:
            compile:
                options:
                    basePath: 'Scripts'
                    preserve_dirs: true
                files: 'Scripts/*.js': 'Scripts/**/*.coffee'

    # Plugins
    grunt.loadNpmTasks 'grunt-contrib-coffee'

当我运行 grunt:grunt coffee 时出现以下错误:

无法写入“Scripts/*.js”文件(错误代码:ENOENT)。使用 --force 继续

【问题讨论】:

标签: coffeescript gruntjs


【解决方案1】:

这样使用:

coffee:
  compile:
    files: [
      expand: true
      cwd: "./Scripts"
      src: ["**/*.coffee"]
      dest: "./Scripts"
      ext: ".js"       
    ]

在此处了解更多信息:http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-15
    • 2018-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多