2015-10-21 111 views
0

我在編寫本機函數時遇到問題,它會將我的文件從一個目錄複製到另一個目錄,並排除某些文件和目錄。Grunt Task - Movig文件從一個文件夾到另一個文件夾

module.exports = function(grunt) { 
    grunt.initConfig({ 
     //.... 
     copy: { 
      prod: { 
       src: ["./src/*"], 
       dest: ["build/"] 
      } 
     } 
    } 
} 

這裏是我的自定義任務負載:

grunt.loadNpmTasks('copy', function(){ 
     var src = grunt.config.get('copy.src'), 
      dest = grunt.config.get('copy.dest'), 
      grunt.file.copy(src, dest); 
    }); 

我在控制檯收到此錯誤:

警告:任務 「拷貝」 找不到。

不過,我覺得這是本地咕嚕功能regarging到: http://gruntjs.com/api/grunt.file

然後我督促這個樣子的:

grunt.registerTask("prod", ["concat", "uglify", "htmlmin", "imagemin", "copy"]); 

回答

0

回答我贏的問題是相當愚蠢的,但也許別人會運行解決這個問題。所以這裏是...

我覺得這畢竟不是本地的咕嚕聲功能。你可以安裝「複製」並且不需要編寫任務載入功能。

從安裝副本:

npm install grunt-contrib-copy --save-dev 

更多的插件在: https://github.com/gruntjs/grunt-contrib-copy

我重新配置我的複製任務在init這樣:

 copy: { 
      prod: { 
       files: [ 
        {expand: true, src: ['./src/**'], dest: 'build/'} 
       ] 
      } 
     } 

並列入

grunt.loadNpmTasks('grunt-contrib-copy'); 

就是這樣。它現在有效。

相關問題