2013-10-04 23 views
1

我想將許多JavaScript文件連接到函數調用中。grunt.js - 將concat javascripts轉換爲函數調用

因此,我想是這樣的:

(function() { 

    // contents of file 1 
    // contents of file 2 
    // contents of file .. 

})() 

在咕嚕-的contrib-CONCAT包沒有這樣的選擇。此外,我沒有找到任何包。

任何想法如何做到這一點?

回答

0

你可以用grunt-contrib-concat來解決這個問題。使用這樣的橫幅和頁腳選項:

concat: { 
    options: { 
     banner: '(function() {\n', 
     footer: '\n})()' 
    }, 
    dist: { 
     src: ['file1.js', 'file2.js'], 
     dest: '' 
    } 
} 
+0

這正是我後來發現的。 :) 謝謝! – radmen