browserify-exec
browserify inliner for shell commands at build time.
This module is a transform for browserify to allow you to execute shell commands at build time and inline the results into your bundle.
Install
npm install browserify-exec
Example
example/main.js
:
var exec = ; var date = ;var hashObjectForThisFile = ; console;console;
And in the command line:
$ browserify -t browserify-exec example/main.js > bundle.js
You will see this in the bundle:
var date = "Fri Mar 18 11:36:36 EDT 2016";var hashObjectForThisFile = "c1e51983f9fba8ef1ab17b58e868fe77ac6a9dc2\n";
Or you can use the API of browserify:
var browserify = ;var b = ;b;b;
Usage
browserify-exec
builds on top of static-module so to use it, you first need to require the module by
var exec =
Then you can use exec
anywhere by passing in a command line string to execute. The result will be inlined and will replace the exec
call. You also have access to __filename and __dirname variables in the arguments to exec
.
Related
Please also checkout these related transforms: