javascript - Is there grunt plugin for wrapping code into Self-Executing Anonymous Functions like in BackboneJS? -



javascript - Is there grunt plugin for wrapping code into Self-Executing Anonymous Functions like in BackboneJS? -

i have sone javascript code need overlap self-executing anonymous functions backbonejs does:

(function(root, factory) { // set backbone appropriately environment. start amd. if (typeof define === 'function' && define.amd) { define(['underscore', 'jquery', 'exports'], function(_, $, exports) { // export global in amd case in case script loaded // others may still expect global backbone. root.backbone = factory(root, exports, _, $); }); // next node.js or commonjs. jquery may not needed module. } else if (typeof exports !== 'undefined') { var _ = require('underscore'); factory(root, exports, _); // finally, browser global. } else { root.backbone = factory(root, {}, root._, (root.jquery || root.zepto || root.ender || root.$)); } }(this, function(root, backbone, _, $) {

the reply yes, if want split file pieces , after concatenation have within function this

(function(){ // file 1 content // file 2 content })();

you need grunt.loadnpmtasks('grunt-contrib-concat'); , define banner , footer:

concat: { app: { options: { separator: ';\n', banner: '(function(){\n', footer: '\n})();' }, src: [ 'src/*.js' ], dest: 'app.js' } },

javascript backbone.js gruntjs

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -