32

Ubuntu 12.04に最新のGruntをインストールしました。ここに私のうなり声があります:

module.exports = function(grunt){
//project configuration
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    concat: {
        slides :  {
            src : ['src/top.html', 'src/bottom.html'],
            dest : ['build/index.html']
        }
    }
});

//enable plugins
grunt.loadNpmTasks('grunt-contrib');
grunt.registerTask('default', ['concat:slides']);
}

これにより build/ ディレクトリが正常に作成されますが、次の出力が得られます。

"concat:slides" (concat) タスクの実行中 警告: "build/index.html" ファイルを書き込めません (エラー コード: 未定義)。--force を使用して続行します。

権限に関係があるのではないかと思ったので、ディレクトリで chmod 777 を実行してみましたが、何も変わらないようでした。

Grunt が build/index.html に書き込むようにするにはどうすればよいですか?

4

2 に答える 2

82

理解した:

//Does not work
dest : ['build/index.html']

文字列として機能しますが、配列としては機能しません。

//Works
dest : 'build/index.html'
于 2013-03-20T12:21:56.877 に答える
0

dest の配列を受け入れるように、tasks/concat.js を変更しました。

// Write the destination file.
// If f.dest is an array take the first element
var dest  = ([].concat(f.dest))[0]
grunt.file.write(dest, src);

しかし後で、src/dest の代わりにファイル形式を使用することにしました。

files: { 'dest.js': ['a.js', 'b.js'] }
于 2013-12-03T14:34:56.803 に答える