gulp-require-convert
v0.0.1
Published
A plugin for Gulp
Downloads
179
Readme
gulp-require-convert
CommonJS module to AMD converter plugin for gulp
Overview
Require-convert will convert CommonJs files that look like this:
var foo = require('foo');
module.exports = foo;
and wrap them in a basic AMD define like this:
define(function (require, exports, module) {
var foo = require('foo');
module.exports = foo;
});
This plugin uses the RequireJS Optimizer's internal convert function for converting modules. This function will only wrap your file in a define call if it does not already have a define call AND if it appears to be a CommonJS module.
Usage
First, install gulp-require-convert
as a development dependency:
npm install --save-dev gulp-require-convert
Then, add it to your gulpfile.js
:
var requireConvert = require("gulp-require-convert");
gulp.src("./src/*.js")
.pipe(requireConvert())
.pipe(gulp.dest("./dist"));