Skip to content

Commit 5cbfa34

Browse files
author
Robin Thrift
committed
added README
1 parent 40d8969 commit 5cbfa34

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#gulp-requirejs
2+
3+
## Information
4+
5+
A small, simply, very easy wrapper around the [require.js optimizer](https://github.com/jrburke/r.js) to work with [gulp.js](https://github.com/gulpjs/gulp)
6+
7+
<table>
8+
<tr>
9+
<td>Package</td><td>gulp-requirejs</td>
10+
</tr>
11+
<tr>
12+
<td>Description</td>
13+
<td>uses require.js's r.js optimizer to combine require.js AMD modules into one file</td>
14+
</tr>
15+
<tr>
16+
<td>Node Version</td>
17+
<td>>= 0.4</td>
18+
</tr>
19+
</table>
20+
21+
## Usage
22+
23+
Because the require.js optimizer (_r.js_) is a kind of build system in itself we can't use the `gulp.src([...])` syntax at the moment (I might add this in future), instead this wrapper itself emits a pipable stream, holding a 'virtual' file, in which the result of the r.js build process are saved.
24+
25+
The resulting stream can be treated like a regular `gulp.src(...)` stream.
26+
27+
>NOTE: The built in minification/obfuscation is deactivated by default and can not be switched on. Please use a gulp plugin like gulp-uglify for this.
28+
29+
```javascript
30+
var gulp = require('gulp'),
31+
rjs = require('gulp-requirejs');
32+
33+
gulp.task('requirejsBuild', function() {
34+
rjs({
35+
baseUrl: 'path/to/your/base/file.js',
36+
out: 'FILENAME\_TO\_BE\_OUTPUTTED',
37+
shim: {
38+
// standard require.js shim options
39+
},
40+
// ... more require.js options
41+
})
42+
.pipe(gulp.dest('./delpoy/')); // pipe it to the output DIR
43+
});
44+
```
45+
46+
### Error handling
47+
48+
gulp-requirejs will emit errors when you don't pass an options object and if the `baseUrl` or `out` properties are undefined.
49+
50+
The requiere.js optimizer itself might also emit errors; unfortunately there's no way of catching them elegantly at the moment.
51+
52+
53+
## Options
54+
55+
The options object supports the same parameters as the [require.js optimizer](https://github.com/jrburke/r.js).
56+

0 commit comments

Comments
 (0)