繁体   English   中英

grunt.js-将concat javascripts纳入函数调用

[英]grunt.js - concat javascripts into function call

我想将许多Javascript文件合并到函数调用中。

结果,我想要得到这样的东西:

(function() {

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

})()

在grunt-contrib-concat软件包中没有这种选择。 我也没有找到任何包装。

任何想法如何做到这一点?

您可以使用grunt-contrib-concat解决此问题。 使用横幅和页脚选项,如下所示:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM