RequireJS skeleton for modern JS libraries.
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).
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.
If your project does require a browser, start a webserver in the root directry.
...and browse to http://localhost:8000/test/runner.html
Start by installing grunt and a few required tasks:
npm install -g gruntnpm 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 testgrunt requirejs
To run tests, optimize and minify your library with a single command, call grunt with no arguments.
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).
- How to set the path and environment variables in Windows
- Where does $PATH get set in OS X 10.6 Snow Leopard?
- How do I change the PATH variable in Linux
- @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.