Call to require JS in index.html
<script src="/javascripts/vendor/requirejs/require.js" data-main="/javascripts/main.js"></script>
The data-main
is main.js
, code here:
require
Call to require JS in index.html
<script src="/javascripts/vendor/requirejs/require.js" data-main="/javascripts/main.js"></script>
The data-main
is main.js
, code here:
require
{ | |
"name": "Durandal Mimosa Skeleton", | |
"version": "2.0.0", | |
"dependencies": { | |
"jquery":"1.9.1", | |
"requirejs":"2.1.8", | |
"requirejs-text":"2.0.3", | |
"knockout.js":"2.3.0", | |
"bootstrap":"2.3.2", | |
"font-awesome":"3.2.1", |
So lets say I have some small bit of library code that I develop and test in isolation. I use RequireJS during development and have a root level file that depends on 1 other file. So it's define
looks something like...
// lib/main.js
define(['lib/dep1'] function(dep1) {
...
})
I run r.js on the code which results in dist/myLibrary.js
, which looks something like this:
express = require 'express' | |
routes = require './routes' | |
exports.startServer = (config, callback) -> | |
require('zappajs') -> | |
@use 'favicon', 'bodyParser', 'methodOverride', 'compress', @app.router, static: config.watch.compiledDir | |
@set | |
'view engine': config.server.views.extension | |
'views': config.server.views.path |
# All of the below are mimosa defaults and only need to be uncommented in the event you want | |
# to override them. | |
# | |
# IMPORTANT: Be sure to comment out all of the nodes from the base to the option you want to | |
# override. If you want to turn change the source directory you would need to uncomment watch | |
# and sourceDir. Also be sure to respect coffeescript indentation rules. 2 spaces per level | |
# please! | |
exports.config = { | |
### |
class Foo | |
@a = "foo" | |
b = 10 | |
# this constructor isn't that constructor, obviously | |
constructor: -> | |
console.log Foo.a | |
// "foo" | |
foo = new Foo() |