Movatterモバイル変換


[0]ホーム

URL:


Browserify lets you require('modules') in the browser by bundling up all of your dependencies.

Get Professional Support for Browserify

Install

use Browserify from the Command Line

First installnode, which ships withnpm. Then do:
npm install -gbrowserify

Hello World With Browserify

Bundle up your first module

Browsers don't have therequire method defined, but Node.js does. With Browserify you can write code that usesrequire in the same way that you would use it in Node.

Here is a tutorial on how to use Browserify on the command line to bundle up a simple file calledmain.js along with all of its dependencies:

main.js
var unique =require('uniq');var data =[1, 2, 2, 3, 4, 5, 5, 5, 6];console.log(unique(data));
Install theuniq module withnpm:
npm install uniq
Now recursively bundle up all the required modules starting atmain.js into a single file calledbundle.js with thebrowserify command:
browserifymain.js -obundle.js
Browserify parses theAST forrequire() calls to traverse the entire dependency graph of your project.
Drop a single<script> tag into your html and you're done!
<script src="bundle.js"></script>

More

  • Read theBrowserify Handbook
  • Use many of the tens of thousands of modules on NPM in the browser
  • Usewatchify, a browserify compatible caching bundler, for super-fast bundle rebuilds as you develop.
  • Usetinyify for optimized, tree-shaked bundles in production environments.
  • Use--debug when creating bundles to have Browserify automatically include Source Maps for easy debugging.
  • Check out tools likeBeefy orrun-browser which make automating browserify development easier.
  • process.nextTick(),__dirname, and__filename node-isms work
  • Get browser versions of the node core librariesevents,stream,path,url,assert,buffer,util,querystring,http,vm, andcrypto when yourequire() them

Community

Joinirc.freenode.net/#browserify for help, or tweet@browserify.

Who Uses Browserify

here are some things people have said

Browserify is elegant and fast. It makes frontend development fun again! That's why we used it to build Yahoo's new HTML5 video player.-feross, developer on the Video team atYahoo.
At Mapbox we build our website and JavaScript API with Browserify. It makes the structure and modularity of our code rock.-tmcw, developer atMapbox.
Browserify does exactly what it says it does and it does it well. I'm glad it exists.-zpao, developer on theReact team at Facebook.
Browserify radically sped up builds, simplified builds and encouraged modularity.-terinjokes, developer at CloudFlare.
View more at theBrowserify in the wild page.

This website is open source and you can fork iton GitHub. CSS was originally forked fromthe-gss.


[8]ページ先頭

©2009-2026 Movatter.jp