https://github.com/unclechu/grunt-amdwrap
A Grunt plugin for wrapping JS-modules written in AMD style
https://github.com/unclechu/grunt-amdwrap
Last synced: 5 months ago
JSON representation
A Grunt plugin for wrapping JS-modules written in AMD style
- Host: GitHub
- URL: https://github.com/unclechu/grunt-amdwrap
- Owner: unclechu
- License: gpl-3.0
- Created: 2014-03-29T16:14:34.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-29T21:24:43.000Z (over 12 years ago)
- Last Synced: 2025-10-08T19:31:57.258Z (9 months ago)
- Size: 180 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
grunt-amdwrap
=============
A Grunt plugin for wrapping JS-modules written in AMD style
Wrap your AMD modules before concat with [RequireJS](http://requirejs.org/)
Wrapped AMD modules will have ids by local "define" wrappers
Getting Started
===============
Install this grunt plugin next to your project's
[grunt.js gruntfile](http://gruntjs.com/getting-started "Getting Started")
with: ``npm install grunt-amdwrap``
Then add this line to your project's ``grunt.js`` gruntfile:
```javascript
grunt.loadNpmTasks('grunt-amdwrap');
```
Documentation
=============
```javascript
grunt.initConfig({
amdwrap: {
libs: {
options: { dir: 'libs' },
files: [
{
expand: true,
cwd: 'scripts/libs/',
src: [ '**/*.js' ],
dest: 'scripts/build/wrap/libs/',
},
],
},
src: {
files: [
{
expand: true,
cwd: 'scripts/src/',
src: [ '**/*.js' ],
dest: 'scripts/build/wrap/',
},
],
},
},
});
```
Wrapper code
============
```javascript
;(function isolate() {
function define() {
var args = Array.prototype.slice.call(arguments, 0);
if (typeof args[0] !== 'string') {
args.unshift('%MODULE_ID%');
}
window.define.apply(this, args);
}
define.amd = { jQuery: true };
// module contents
})();
```
Author
======
Viacheslav Lotsmanov
License
=======
GNU/GPLv3 by Free Software Foundation