From 9f4d6f442b578053bd4280030e50a5e91ee52d4a Mon Sep 17 00:00:00 2001 From: "Eduardo L. Buratti" <elb09@c3sl.ufpr.br> Date: Mon, 21 Oct 2013 09:13:57 -0200 Subject: [PATCH] web: Add uglification/concatenation of javascript files Signed-off-by: Eduardo L. Buratti <elb09@c3sl.ufpr.br> --- web/.gitignore | 3 + web/Gruntfile.js | 70 ++++++++++++++++++--- web/app/css/.gitignore | 1 - web/app/index.html | 10 +-- web/{app => assets}/js/app.js | 0 web/{app => assets}/js/attendance.js | 0 web/{app => assets}/js/attendance.search.js | 0 web/{app => assets}/js/default-charts.js | 0 web/{app => assets}/js/doc.js | 0 web/{app => assets}/js/fake-data.js | 0 web/{app => assets}/js/global.js | 0 web/{app => assets}/js/install.js | 0 web/package.json | 4 +- 13 files changed, 67 insertions(+), 21 deletions(-) delete mode 100644 web/app/css/.gitignore rename web/{app => assets}/js/app.js (100%) rename web/{app => assets}/js/attendance.js (100%) rename web/{app => assets}/js/attendance.search.js (100%) rename web/{app => assets}/js/default-charts.js (100%) rename web/{app => assets}/js/doc.js (100%) rename web/{app => assets}/js/fake-data.js (100%) rename web/{app => assets}/js/global.js (100%) rename web/{app => assets}/js/install.js (100%) diff --git a/web/.gitignore b/web/.gitignore index 290d260..46f4825 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -11,6 +11,9 @@ pids logs results node_modules + app/components +app/css +app/js npm-debug.log diff --git a/web/Gruntfile.js b/web/Gruntfile.js index 96934b9..d8ef819 100644 --- a/web/Gruntfile.js +++ b/web/Gruntfile.js @@ -1,22 +1,72 @@ module.exports = function (grunt) { grunt.initConfig({ less: { - development: { - files: [{ - expand: true, - cwd: 'assets/less', - src: ['main.less'], - dest: 'app/css', - ext: '.css', - }] + dev: { + options: { + paths: ["assets/less"] + }, + files: { + 'app/css/main.css': 'assets/less/main.less' + } + }, + prod: { + options: { + paths: ["assets/less"], + yuicompress: true + }, + files: { + 'app/css/main.css': 'assets/less/main.less' + } + } + }, + uglify: { + prod: { + options: { + mangle: false + }, + files: { + 'app/js/main.js': [ + 'assets/js/app.js', + 'assets/js/attendance.js', + 'assets/js/attendance.search.js', + 'assets/js/default-charts.js', + 'assets/js/doc.js', + 'assets/js/fake-data.js', + 'assets/js/global.js', + 'assets/js/install.js' + ] + } + } + }, + concat: { + dev: { + files: { + 'app/js/main.js': [ + 'assets/js/app.js', + 'assets/js/attendance.js', + 'assets/js/attendance.search.js', + 'assets/js/default-charts.js', + 'assets/js/doc.js', + 'assets/js/fake-data.js', + 'assets/js/global.js', + 'assets/js/install.js' + ] + } } }, watch: { - files: ['assets/less/**/*.less'], - tasks: ['less'] + dev: { + files: ['assets/**/*'], + tasks: ['less:dev', 'concat:dev'] + } } }); grunt.loadNpmTasks('grunt-contrib-less'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-watch'); + + grunt.registerTask('default', ['less:dev', 'concat:dev']); + grunt.registerTask('prod', ['less:prod', 'uglify:prod']); }; diff --git a/web/app/css/.gitignore b/web/app/css/.gitignore deleted file mode 100644 index 96f805b..0000000 --- a/web/app/css/.gitignore +++ /dev/null @@ -1 +0,0 @@ -main.css diff --git a/web/app/index.html b/web/app/index.html index bb228c5..d98e713 100644 --- a/web/app/index.html +++ b/web/app/index.html @@ -30,14 +30,6 @@ <script src="components/angular-resource/angular-resource.js"></script> <script src="components/angular-ui-router/release/angular-ui-router.js"></script> <script src="components/highcharts/highcharts.js"></script> - <script src="js/global.js"></script> - <script src="js/default-charts.js"></script> - <script src="js/app.js"></script> - <script src="js/install.js"></script> - <script src="js/doc.js"></script> - <script src="js/attendance.js"></script> - <script src="js/attendance.search.js"></script> - - <script src="js/fake-data.js"></script> + <script src="js/main.js"></script> </body> </html> \ No newline at end of file diff --git a/web/app/js/app.js b/web/assets/js/app.js similarity index 100% rename from web/app/js/app.js rename to web/assets/js/app.js diff --git a/web/app/js/attendance.js b/web/assets/js/attendance.js similarity index 100% rename from web/app/js/attendance.js rename to web/assets/js/attendance.js diff --git a/web/app/js/attendance.search.js b/web/assets/js/attendance.search.js similarity index 100% rename from web/app/js/attendance.search.js rename to web/assets/js/attendance.search.js diff --git a/web/app/js/default-charts.js b/web/assets/js/default-charts.js similarity index 100% rename from web/app/js/default-charts.js rename to web/assets/js/default-charts.js diff --git a/web/app/js/doc.js b/web/assets/js/doc.js similarity index 100% rename from web/app/js/doc.js rename to web/assets/js/doc.js diff --git a/web/app/js/fake-data.js b/web/assets/js/fake-data.js similarity index 100% rename from web/app/js/fake-data.js rename to web/assets/js/fake-data.js diff --git a/web/app/js/global.js b/web/assets/js/global.js similarity index 100% rename from web/app/js/global.js rename to web/assets/js/global.js diff --git a/web/app/js/install.js b/web/assets/js/install.js similarity index 100% rename from web/app/js/install.js rename to web/assets/js/install.js diff --git a/web/package.json b/web/package.json index 0087c4e..adb42f7 100644 --- a/web/package.json +++ b/web/package.json @@ -11,6 +11,8 @@ "bower": "~1.2.6", "pg": "~2.5.1", "express": "~3.3.8", - "connect": "~2.9.0" + "connect": "~2.9.0", + "grunt-contrib-uglify": "~0.2.4", + "grunt-contrib-concat": "~0.3.0" } } -- GitLab