Skip to content

Commit 901b81c

Browse files
Documented the programmatic API (fixes #3)
1 parent 733def8 commit 901b81c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,34 @@ dist/module-two.bundle.min.js.map
113113
```
114114

115115

116+
API
117+
--------------------------
118+
Simplifyify also has a programmatic API, so you can use it directly in your build scripts (Gulp, Grunt, Broccoli, etc.)
119+
120+
[Here's the API definition](https://github.com/BigstickCarpet/simplifyify/blob/eba983197e0512619c8818b53f7752e795b42b0b/lib/index.js#L9-L28), and [here's a full example](https://github.com/BigstickCarpet/simplifyify/blob/ce6b47b94f524ed9e66396fb3b5b951b655328ad/bin/simplifyify.js#L51-L75). Just pass an array of strings (file paths and/or glob patterns) and an options param. You get back an [`EventEmitter`](https://nodejs.org/api/events.html#events_class_events_eventemitter), which fires all the Browserify & Watchify events.
121+
122+
```javascript
123+
var simplifyify = require("simplifyify");
124+
125+
gulp.task("browserify", function(done) {
126+
simplifyify("lib/*.module.js",
127+
{
128+
outfile: "dist/*.bundle.js",
129+
debug: true,
130+
minify: true
131+
})
132+
.on("end", function() {
133+
// Finished successfully!
134+
done();
135+
})
136+
.on("error", function(err) {
137+
// Something went wrong
138+
done(err);
139+
});
140+
});
141+
```
142+
143+
116144
Contributing
117145
--------------------------
118146
I welcome any contributions, enhancements, and bug-fixes. [File an issue](https://github.com/BigstickCarpet/simplifyify/issues) on GitHub and [submit a pull request](https://github.com/BigstickCarpet/simplifyify/pulls).
@@ -137,3 +165,4 @@ To build the project locally on your computer:
137165
License
138166
--------------------------
139167
Simplifyify is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
168+
I

0 commit comments

Comments
 (0)