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

        preserveComments: (node, comment) -> !comment.value.lastIndexOf('@license', 0)
      jail_iframe:
        files:
          'build/jail_iframe.min.js':                        ['build/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" \' \\; '

    copy:
      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: '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: '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: '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' }

        ]

      config_development:

      }
      {
        placeholder: '__INLINE_JS_PLACEHOLDER__'
        content_file: 'build/js/jail_iframe.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)
        target_filename = file_variant_func 'build/js/loader/loader_common.js'

        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', 'coffee', 'sass', 'cssUrlEmbed', 'cssmin', ]

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

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