0

/assets/src/coffeeetc (など)に多数のコーヒー ソース ファイルがあり、それらをand./child/pathsに出力したいと考えています。assets/js/assets/js/child/paths

近づいたように見えますが、機能していません。とを使用grunt-contrib-coffeegrunt-contrib-watchます。

grunt.initConfig
watch:
  coffee:
    files: '<%= coffee.src %>',
    tasks: 'coffee:dev'
    options:
      nospawn: true

coffee:
  src: 'assets/src/coffee/**/*.coffee'
  dev:
    options:
      sourceMap: true
    files: [
      expand: true
      cwd: "assets/"
      src: "/src/coffee/**/*.coffee"
      dest: "../js/"
      ext: ".js"
    ]

grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks 'grunt-contrib-watch' 
# Default task.
grunt.registerTask "default", "watch"

grunt.event.on('watch', (action, filepath) ->
(grunt.log.writeln('\n'+ filepath + ' has ' + action))

dest = "#{path.dirname(filepath.replace("src/coffee", "js"))}"

grunt.config(['coffee', 'dev', 'files', 'src'], [filepath])
grunt.config(['coffee', 'dev', 'files', 'dest'], [dest])

(grunt.log.writeln("src: #{grunt.config(['coffee', 'dev', 'files', 'src'])}"))
(grunt.log.writeln("dest: #{grunt.config(['coffee', 'dev', 'files', 'dest'])}"))

)

わかりましたので、その出力は次のようになります。

assets/src/coffee/projAlpha/dl.coffee has changed    
src: assets/src/coffee/projAlpha/dl.coffee    
dest: assets/js/projAlpha/dl.coffee

しかし、ファイルは実際には次のようになります。assets/src/coffee/projAlpha/dl.coffee...そしてそれはコーヒースクリプトです。にあるはずですassets/js/projAlpha/dl.js

すべてのファイルを一度にコンパイルして適切な場所に配置するための grunt coffee ユーティリティを入手しました。ただし、ファイルがいくつかあり、常にファイルを追加しているので、一度に 1 つずつコンパイルしたほうがよいでしょう。

4

1 に答える 1