diff --git a/Gruntfile.js b/Gruntfile.js index 747d51f86..ca5f573f0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,6 +59,41 @@ module.exports = function (grunt) { } } }, + obfuscator: { + options: { + compact: true, + controlFlowFlattening: true, + controlFlowFlatteningThreshold: 1, + deadCodeInjection: true, + deadCodeInjectionThreshold: 1, + debugProtection: true, + debugProtectionInterval: true, + disableConsoleOutput: true, + identifierNamesGenerator: 'hexadecimal', + log: false, + renameGlobals: false, + rotateStringArray: true, + selfDefending: true, + stringArray: true, + stringArrayEncoding: 'rc4', + stringArrayThreshold: 1, + transformObjectKeys: true, + unicodeEscapeSequence: false + }, + prod: { + files: { + 'static/dist/js/app.min.js' :'static/js/app.js', + 'static/dist/js/map.min.js':'static/js/map.js', + 'static/dist/js/map.common.min.js' : 'static/js/map.common.js', + 'static/dist/js/mobile.min.js':'static/js/mobile.js', + 'static/dist/js/stats.min.js':'static/js/stats.js', + 'static/dist/js/statistics.min.js':'static/js/statistics.js', + 'static/dist/js/status.min.js':'static/js/status.js', + 'static/dist/js/serviceWorker.min.js':'static/js/serviceWorker.js' + } + } + + }, minjson: { build: { files: { @@ -147,7 +182,8 @@ module.exports = function (grunt) { } }); - grunt.registerTask('js-build', ['newer:babel', 'newer:uglify']); + grunt.registerTask('js-build', ['newer:obfuscator']); + grunt.registerTask('js-dev', ['newer:babel', 'newer:uglify']); grunt.registerTask('css-build', ['newer:sass', 'newer:cssmin']); grunt.registerTask('js-lint', ['newer:eslint']); grunt.registerTask('json', ['newer:minjson']); @@ -155,6 +191,7 @@ module.exports = function (grunt) { grunt.registerTask('html-build', ['htmlmin', 'cacheBust']); grunt.registerTask('build', ['clean', 'js-build', 'css-build', 'json', 'html-build']); + grunt.registerTask('dev', ['clean', 'js-dev', 'css-build', 'json', 'html-build']); grunt.registerTask('lint', ['js-lint', 'php-lint']); grunt.registerTask('default', ['build', 'watch']); diff --git a/package.json b/package.json index 4f16c6e4f..98a8f2a59 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "build": "grunt build", "watch": "grunt default", + "dev": "grunt dev", "lint": "grunt lint", "grunt": "grunt" }, @@ -45,6 +46,7 @@ "grunt-contrib-copy": "latest", "grunt-contrib-cssmin": "latest", "grunt-contrib-htmlmin": "2.4.0", + "grunt-contrib-obfuscator": "latest", "grunt-contrib-uglify": "latest", "grunt-contrib-watch": "latest", "grunt-eslint": "^20.1.0",