FXG
FXG

Reputation: 1378

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

Upvotes: 2

Views: 907

Answers (2)

romuleald
romuleald

Reputation: 1444

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

Upvotes: 3

deowk
deowk

Reputation: 4318

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.

Upvotes: 1

Related Questions