Skip to content

tkellen/requirejs-library-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RequireJS skeleton for modern JS libraries.

Build Status

This template is a starting point for developing modern javascript modules and libraries. Dependency management is handled by the AMD loader RequireJS. Unit testing is implemented with the BDD framework Jasmine. Compilation is handled with r.js and almond via node, or using the javascript build tool grunt

Whichever method you use, the result is a single file with no external dependencies that runs in Node or the browser (with AMD, or as an inline script).

Building / Testing with Node

Kick off the requirejs optimizer by hand:

node vendor/r.js -o build.js

If your project does not require a browser environment, run Jasmine tests with node.

node test/runner-node

If your project does require a browser, start a webserver in the root directry.

servedir

...and browse to http://localhost:8000/test/runner.html

Building / Testing / Minifying with Grunt

Start by installing grunt and a few required tasks:

npm install -g grunt
npm install

Then, use grunt to run your tests in a headless browser (PhantomJS), or kick off the RequireJS optimizer from any path inside the root of your project using these commands:

grunt test
grunt requirejs

To run tests, optimize and minify your library with a single command, call grunt with no arguments.

grunt

Headless Browser Testing w/ PhantomJS

In order for the jasmine task to work properly, PhantomJS must be installed. Unfortunately, PhantomJS cannot be installed automatically via npm or grunt, so you need to install it yourself. There are a number of ways to install PhantomJS.

Note that the phantomjs executable needs to be in the system PATH for grunt to see it (if you can run "phantomjs" at the command line, this task should work).

Thanks to

  • @jrburke for the fantastic tools RequireJS/r.js & almond.
  • @cowboy for all of his hard work on Grunt.
  • @pivotal for the intuitive testing framework Jasmine.

About

RequireJS / Jasmine / r.js / almond skeleton for javascript libraries and modules.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published