0

To minify and obfuscate my JS code I'm trying to use Grunt's closure-compiler plugin.

I'm perfectly happy with the result, but after running Grunt I get project.min.js.report.txt file in the output directory. I haven't found any options responsible for that.

The only solution I see is to create another task to remove the file. Are there simplier ways to avoid this file from reappearing?

Here is my gruntfile.js contents:

module.exports = function(grunt) {
    grunt.initConfig({
        "concat": {
            js: {
                src: [
                    "js/project.js"
                ],
                dest: "js/project.all.js"
            }
        },
        "closure-compiler": {
            frontend: {
                closurePath: "path/to/gcc_jar_directory",
                js: "js/project.all.js",
                jsOutputFile: "js/project.min.js",
                maxBuffer: 500,
                options: {
                    compilation_level: "ADVANCED_OPTIMIZATIONS",
                    language_in: "ECMASCRIPT5_STRICT",
                }
            }
        },
        watch: {
            js: {
                files: ["js/project.js"],
                tasks: ["concat:js", "closure-compiler"]
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-closure-compiler");
    grunt.loadNpmTasks("grunt-contrib-watch");

    grunt.registerTask("default", ["concat:js", "closure-compiler", "watch"]);
};
gkond
  • 3,818
  • 2
  • 20
  • 27

3 Answers3

1

You can't as it's currently hard-coded.

Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
1

This is possible now using the noreport option (read more):

'closure-compiler': {
    frontend: {
        closurePath: '/var/www/closure/',
        js: 'js/file.js',
        jsOutputFile: 'js/dist/file.min.js',
        maxBuffer: 500,
        options: {
            compilation_level: 'SIMPLE_OPTIMIZATIONS',
            noreport: true
        }
    }
}
Rob M.
  • 35,491
  • 6
  • 51
  • 50
0

Funny enough, but it's just this Grunt plugin's issue, not Google Closure Compiler.

Created an issue for that.

gkond
  • 3,818
  • 2
  • 20
  • 27