Skip to content

Instantly share code, notes, and snippets.

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
@dbashford
dbashford / bower.json
Last active December 26, 2015 17:49
mimosa-bower mimosa-config mainOverride example. The first file is the pertinent bower.json, the second is the mimosa-config bower snippet. The first comment at the bottom explains the config in detail.
{
"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",
@dbashford
dbashford / gist:6117149
Last active December 20, 2015 10:39
Using a r.js packaged library

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:

@dbashford
dbashford / gist:6059643
Created July 23, 2013 03:26
Mimosa zappa server and live reload
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
@dbashford
dbashford / gist:4132259
Created November 22, 2012 17:25
mimosa-config with server-reload
# 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 = {
###
@dbashford
dbashford / gist:3711415
Created September 13, 2012 02:13
Access class variable via instance
class Foo
@a = "foo"
b = 10
# this constructor isn't that constructor, obviously
constructor: ->
console.log Foo.a
// "foo"
foo = new Foo()