Last active
August 29, 2015 14:12
-
-
Save majgis/433fe8cc89a1b50a24b4 to your computer and use it in GitHub Desktop.
Browserify - expose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require( 'fs' ); | |
var b = require( 'browserify' )(); | |
var outputFile = fs.createWriteStream( './output.js' ); | |
b.add( './index.js' ); | |
b.require( './test.js', {expose: 't'} ); | |
b.bundle().pipe( outputFile ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
browserify index.js -r ./test.js:t > output.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<script src='output.js'></script> | |
<script> | |
require('t')(); | |
//'works!!!' is output to the console | |
</script> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(){ | |
console.log('works!!!') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment