module.exports = function()

in Gruntfile.js [11:94]


module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),

    replace: {
      dist: {
        options: {
          patterns: [
            {
              match: /\{\/\* include\("(.*?)"\) \*\/\}/,
              replacement: (match, filename) => {
                return grunt.file.read(filename)
                  .replace(/\n$/, "")
                  .replace(/^[^{]/gm, "    $&");
              },
            },
            {
              json: {
                "package_name": "<%= pkg.name %>",
                "version": "<%= pkg.version %>",
                "timestamp": "<%= grunt.template.today() %>",
              },
            },
          ],
        },
        files: [
          {
            expand: true,
            flatten: true,
            src: ["src/browser-polyfill.js"],
            dest: "dist/",
          },
        ],
      },
    },

    babel: {
      minify: {
        options: {
          babelrc: false,
          comments: false,
          presets: ["minify"],
          sourceMap: true,
        },
        files: {
          "dist/browser-polyfill.min.js": "dist/browser-polyfill.js",
        },
      },
      umd: {
        options: {
          babelrc: false,
          comments: true,
          plugins: [
            ["./scripts/babel-transform-to-umd-module", {
              globalName: "browser",
              amdModuleName: "webextension-polyfill",
            }],
          ],
          sourceMap: true,
          moduleId: "webextension-polyfill",
        },
        files: {
          "dist/browser-polyfill.js": "dist/browser-polyfill.js",
        },
      },
    },

    concat: {
      license: {
        src: "dist/browser-polyfill.min.js",
        dest: "dist/browser-polyfill.min.js",
        options: {footer: MINIFIED_FILE_FOOTER},
      },
    },
  });

  grunt.util.linefeed = "\n";

  grunt.loadNpmTasks("grunt-replace");
  grunt.loadNpmTasks("grunt-contrib-concat");
  grunt.loadNpmTasks("grunt-babel");

  grunt.registerTask("default", ["replace", "babel:umd", "babel:minify", "concat:license"]);
};