           'dist/index.html': ['index.html']
 
 
-    # This task uses James Burke's excellent r.js AMD builder to take all
-    # modules and concatenate them into a single file.
+    # Inspirational reading: https://github.com/jrburke/r.js/blob/master/build/example.build.js
     requirejs:
       compile:
         options:
           baseUrl: 'tmp/app'
           mainConfigFile: 'tmp/app/config.js'
-          moduleDirs: ["tmp/app"]
+
+          include: ["main"]
+          insertRequire: ["main"]
+          findNestedDependencies: true
+          name: "almond"
+
+          wrap: true
 
           out: 'tmp/application.js'
-          optimize: ''
+          optimize: 'none'
 
           generateSourceMaps: false
           preserveLicenseComments: true
+          waitSeconds: 7
 
 
     copy:

  grunt.loadNpmTasks('grunt-contrib-coffee')

  grunt.loadNpmTasks('grunt-processhtml')
  grunt.loadNpmTasks('grunt-bbb-requirejs')

  grunt.loadNpmTasks('grunt-contrib-copy')
  grunt.loadNpmTasks('grunt-contrib-uglify')

  # Create an aliased test task.
  # grunt.registerTask('test', ['karma:run'])


  grunt.registerTask('dev', [
    'clean'

