简体   繁体   中英

How to grunt concat in a wrapping function

I have three files containing js classes:

A.js
B.js
C.js

I'm trying to concatenate them to get something like:

var Module = (function (scope) {
// content of concatenation (ABC.js)
})(scope);

For now I'm using https://www.npmjs.com/package/grunt-contrib-concat to concatenate, I saw https://www.npmjs.com/package/grunt-wrap , it seems to be abandonned but look like what I want.

Someone has an idea to achieve it without using grunt-concat?

PS: I want to keep a *.map file for debug purpose

Are you looking for the banner/footer of https://github.com/gruntjs/grunt-contrib-concat ?

Or this kind of concatenation with 2 files for intro and outro? I'm trying out Grunt and need a simple way to concatenate my modules

I think you might want to have a look at Browserify and Browserify-shim . It's an excellent way of scoping your dependencies without polluting the global namespace. It's works well with grunt and gulp and supports sourcemaps too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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