Giter VIP home page Giter VIP logo

browserify-test's Introduction

An example of using browserify and browserify-shim to modularize javascript and make it more easily testable.

Setting up a new project with browserify, gulp and jquery

  1. npm install bower browserify browserify-shim gulp gulp-rename gulp-uglify vinyl-buffer vinyl-source-stream
  2. add node_modules to .gitignore
  3. add some required json to package.json to get browserify-shim to work with jquery
  4. bower init and press enter a bunch of times to create a bower.json
  5. bower install --save-dev jquery
  6. add bower_components to .gitignore
  7. create a browserify module in assets/js/mymodule.js - example
  8. create a script that uses it such as assets/js/app.js - example
  9. add a gulpfile.js or just use this one
  10. gulp to create the first build
  11. include the compiled js file in your html with a script tag
  12. If your compiled js is in assets/cache, add it to .gitignore

Installation

  • npm install to get gulp, browserify, bower, etc.
  • bower install to get jquery
  • gulp build to compile app.min.js to assets/cache
  • load index.html in your browser

Notes

  • there are a few important configs under the browser, browserify and browserify-shim keys in package.json
  • browserify cannot stream to another task unless you use vinyl-source-stream to define a source and vinyl-buffer to buffer before continuing.
  • sourcemaps are a bit difficult since browserify has it's own sourcemaps it generates via --debug.

browserify-test's People

Contributors

mikedfunk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.