         preserveComments: (node, comment) -> !comment.value.lastIndexOf('@license', 0)
       jail_iframe:
         files:
-          'build/jail_iframe.min.js':                        ['build/jail_iframe.js']
+          'build/js/jail_iframe.min.js':                        ['build/js/jail_iframe.js']
       factlink_loader:
         files:
           'build/js/loader/loader_common.min.js':       ['build/js/loader/loader_common.js']
     shell:
       gzip_js_files:
-        command: ' find build/ -iname \'*.js\'  -maxdepth 1  -exec bash -c \' gzip -9 -f < "{}" > "{}.gz" \' \\; '
+        command: ' find build/js/loader/ -iname \'*.js\'  -maxdepth 1  -exec bash -c \' gzip -9 -f < "{}" > "{}.gz" \' \\; '
 
     copy:
-      loader_aliases:
+      dist_loader_aliases:
         files: [
-          { src: 'js/loader/loader_common.js', cwd: 'build/', dest: 'factlink_loader_basic.js' }
-          { src: 'js/loader/loader_common.js', cwd: 'build/', dest: 'factlink_loader_publishers.js' }
-          { src: 'js/loader/loader_common.js', cwd: 'build/', dest: 'factlink_loader_bookmarklet.js' }
+          { src: 'build/js/loader/loader_common.js', dest: 'output/dist/factlink_loader_basic.js' }
+          { src: 'build/js/loader/loader_common.js', dest: 'output/dist/factlink_loader_publishers.js' }
+          { src: 'build/js/loader/loader_common.js', dest: 'output/dist/factlink_loader_bookmarklet.js' }
           
-          { src: 'js/loader/loader_common.min.js', cwd: 'build/', dest: 'factlink_loader_basic.min.js' }
-          { src: 'js/loader/loader_common.min.js', cwd: 'build/', dest: 'factlink_loader_publishers.min.js' }
-          { src: 'js/loader/loader_common.min.js', cwd: 'build/', dest: 'factlink_loader_bookmarklet.min.js' }
+          { src: 'build/js/loader/loader_common.min.js', dest: 'output/dist/factlink_loader_basic.min.js' }
+          { src: 'build/js/loader/loader_common.min.js', dest: 'output/dist/factlink_loader_publishers.min.js' }
+          { src: 'build/js/loader/loader_common.min.js', dest: 'output/dist/factlink_loader_bookmarklet.min.js' }
           
-          { src: 'js/loader/loader_common.js.gz', cwd: 'build/', dest: 'factlink_loader_basic.js.gz' }
-          { src: 'js/loader/loader_common.js.gz', cwd: 'build/', dest: 'factlink_loader_publishers.js.gz' }
-          { src: 'js/loader/loader_common.js.gz', cwd: 'build/', dest: 'factlink_loader_bookmarklet.js.gz' }
+          { src: 'build/js/loader/loader_common.js.gz', dest: 'output/dist/factlink_loader_basic.js.gz' }
+          { src: 'build/js/loader/loader_common.js.gz', dest: 'output/dist/factlink_loader_publishers.js.gz' }
+          { src: 'build/js/loader/loader_common.js.gz', dest: 'output/dist/factlink_loader_bookmarklet.js.gz' }
 
-          { src: 'js/loader/loader_common.min.js.gz', cwd: 'build/', dest: 'factlink_loader_basic.min.js.gz' }
-          { src: 'js/loader/loader_common.min.js.gz', cwd: 'build/', dest: 'factlink_loader_publishers.min.js.gz' }
-          { src: 'js/loader/loader_common.min.js.gz', cwd: 'build/', dest: 'factlink_loader_bookmarklet.min.js.gz' }
-
+          { src: 'build/js/loader/loader_common.min.js.gz', dest: 'output/dist/factlink_loader_basic.min.js.gz' }
+          { src: 'build/js/loader/loader_common.min.js.gz', dest: 'output/dist/factlink_loader_publishers.min.js.gz' }
+          { src: 'build/js/loader/loader_common.min.js.gz', dest: 'output/dist/factlink_loader_bookmarklet.min.js.gz' }
         ]
 
       config_development:

      }
      {
        placeholder: '__INLINE_JS_PLACEHOLDER__'
        content_file: 'build/jail_iframe.js'
      }
    ]
    targets = [
      'build/factlink_loader_basic.js'
      'build/factlink_loader_bookmarklet.js'
      'build/factlink_loader_publishers.js'
    ]
    file_variant_funcs.forEach (file_variant_func) ->
        replacements.forEach (replacement) ->
          input_filename = file_variant_func(replacement.content_file)
          input_content = grunt.file.read(input_filename, 'utf8')
          input_content_stringified = JSON.stringify(input_content)
          targets.map(file_variant_func).forEach (target_filename) ->
            grunt.log.writeln "Inlining '#{input_filename}' into '#{target_filename}' where  '#{replacement.placeholder}'."
            target_content = grunt.file.read target_filename, 'utf8'
            target_with_inlined_content = target_content.replace replacement.placeholder, input_content_stringified
            grunt.file.write(target_filename, target_with_inlined_content)

  grunt.registerTask 'preprocessor',  [
    'clean', 'copy:build', 'copy:extension_events', 'coffee', 'sass', 'cssUrlEmbed', 'cssmin', ]

  grunt.registerTask 'postprocessor', [
    'concat', 'mocha', 'uglify', 'code_inliner', 'shell:gzip_js_files', 'copy:dist' ]

  grunt.registerTask 'compile_develop',   [ 'preprocessor', 'copy:config_development', 'postprocessor' ]
  grunt.registerTask 'compile_staging',   [ 'preprocessor', 'copy:config_staging',     'postprocessor' ]

        files: [
          { src: ['**/*.js', '**/*.png', '**/*.gif', '**/*.woff', 'robots.txt'], cwd: 'app', dest: 'build', expand: true }
        ]
      dist_static_content:
        files: [
          { src: ['robots.txt', 'images/**/*'], cwd: 'build', dest: 'output/dist', expand: true }
        ]
    watch:
      files: ['app/**/*', 'Gruntfile.coffee']
