From b9466505f55bf99d8f93beab1e7f0fdce7b64319 Mon Sep 17 00:00:00 2001 From: Levi Bostian Date: Sat, 18 Oct 2014 13:19:07 -0500 Subject: [PATCH] Attempt at fixing amd file's markdown on site. --- amd.html.markdown | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/amd.html.markdown b/amd.html.markdown index 36210d03..b3237dc7 100644 --- a/amd.html.markdown +++ b/amd.html.markdown @@ -136,6 +136,7 @@ require(['jquery', 'coolLibFromBower', 'modules/someHelpers'], function($, coolL }); ``` `require.js`-based apps will usually have a single entry point (`main.js`) that is passed to the `require.js` script tag as a data-attribute. It will be automatically loaded and executed on pageload: + ```html @@ -155,13 +156,15 @@ Many people prefer using AMD for sane code organization during development, but `require.js` comes with a script called `r.js` (that you will probably run in node.js, although Rhino is supported too) that can analyse your project's dependency graph, and build a single file containing all your modules (properly named), minified and ready for consumption. Install it using `npm`: -```sh +```shell $ npm install requirejs -g ``` + Now you can feed it with a configuration file: -```sh +```shell $ r.js -o app.build.js ``` + For our above example the configuration might look like: ```javascript /* file : app.build.js */ @@ -177,10 +180,12 @@ For our above example the configuration might look like: } }) ``` + To use the built file in production, simply swap `data-main`: ```html ``` + An incredibly detailed [overview of build options](https://github.com/jrburke/r.js/blob/master/build/example.build.js) is available in the GitHub repo. ### Topics not covered in this tutorial