From 4ccb9891a8a3b4b025e0593802d111280b7d7909 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Thu, 18 Feb 2016 14:45:11 +0100 Subject: [PATCH] Add basic distribution for accountant web. --- Gruntfile.js | 13 +++++++++++++ grunt-config/clean.js | 2 +- grunt-config/copy.js | 22 +++++++++++++++++++--- grunt-config/filerev.js | 17 +++++++++++++++++ grunt-config/usemin.js | 16 ++++++++++++++++ grunt-config/useminPrepare.js | 17 +++++++++++++++++ package.json | 8 ++++++-- 7 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 grunt-config/filerev.js create mode 100644 grunt-config/usemin.js create mode 100644 grunt-config/useminPrepare.js diff --git a/Gruntfile.js b/Gruntfile.js index 6e07c9b..23fff3e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -57,4 +57,17 @@ module.exports = function(grunt) { 'bgShell:runserver', 'watch' ]); + + grunt.registerTask('dist', [ + 'wiredep', + 'clean:dist', + 'useminPrepare', + 'copy:dist', + 'copy:styles', + 'concat:generated', + 'cssmin:generated', + 'uglify:generated', + 'filerev', + 'usemin' + ]); }; diff --git a/grunt-config/clean.js b/grunt-config/clean.js index 6d0fc1e..0881828 100644 --- a/grunt-config/clean.js +++ b/grunt-config/clean.js @@ -1,7 +1,7 @@ 'use strict'; module.exports = { - libs: [ + dist: [ '<%= accountant.frontend.dist %>' ] }; diff --git a/grunt-config/copy.js b/grunt-config/copy.js index f784cd3..388ee5e 100644 --- a/grunt-config/copy.js +++ b/grunt-config/copy.js @@ -1,6 +1,22 @@ +'use strict'; + module.exports = { - "bootstrap-select.css.map": { - src: 'bower_components/bootstrap-select/dist/css/bootstrap-select.css.map', - dest: '<%= paths.frontend_build %>/css/bootstrap-select.css.map' + dist: { + files: [{ + expand: true, + dot: true, + cwd: '<%= accountant.frontend.src %>', + dest: '<%= accountant.frontend.dist %>', + src :[ + '*.html', + 'views/*.html', + ] + }] }, + styles: { + expand: true, + cwd: '<%= accountant.frontend.src %>/css', + dest: '.tmp/css', + src: '{,*/}*.css' + } }; diff --git a/grunt-config/filerev.js b/grunt-config/filerev.js new file mode 100644 index 0000000..e6448db --- /dev/null +++ b/grunt-config/filerev.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + options: { + encoding: 'utf-8', + algorithm: 'md5', + length: 8 + }, + dist: { + src: [ + '<%= accountant.frontend.dist %>/css/*.css', + '<%= accountant.frontend.dist %>/js/*.js', + '!<%= accountant.frontend.dist %>/css/*.map.css', + '!<%= accountant.frontend.dist %>/js/*.map.js' + ] + }, +}; diff --git a/grunt-config/usemin.js b/grunt-config/usemin.js new file mode 100644 index 0000000..2c956d2 --- /dev/null +++ b/grunt-config/usemin.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports = { + html: ['<%= accountant.frontend.dist %>/{,*/}*.html'], + css: ['<%= accountant.frontend.dist %>/css/{,*/}*.css'], + js: ['<%= accountant.frontend.dist %>/js/{,*/}*.js'], + options: { + assetsDir: [ + '<%= accountant.frontend.dist %>', + '<%= accountant.frontend.dist %>/css', + ], + patterns: { + js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']] + } + } +}; diff --git a/grunt-config/useminPrepare.js b/grunt-config/useminPrepare.js new file mode 100644 index 0000000..00d5f55 --- /dev/null +++ b/grunt-config/useminPrepare.js @@ -0,0 +1,17 @@ +'use strict'; + +module.exports = { + html: '<%= accountant.frontend.src %>/index.html ', + options: { + dest: '<%= accountant.frontend.dist %>', + flow: { + html: { + steps: { + js: ['concat', 'uglify'], + css: ['cssmin'] + }, + post: {} + } + } + } +}; diff --git a/package.json b/package.json index 60c6eeb..2141cb0 100644 --- a/package.json +++ b/package.json @@ -6,17 +6,21 @@ "devDependencies": { "grunt": "^0.4.5", "grunt-bg-shell": "^2.3.1", - "grunt-contrib-clean": "^0.7.0", + "grunt-contrib-clean": "^1.0.0", "grunt-contrib-concat": "^0.5.1", - "grunt-contrib-jshint": "^0.12", + "grunt-contrib-cssmin": "^0.14.0", + "grunt-contrib-jshint": "^1.0.0", + "grunt-contrib-uglify": "^0.11.1", "grunt-contrib-watch": "^0.6.1", "grunt-copy": "^0.1.0", + "grunt-filerev": "^2.3.1", "grunt-flake8": "^0.1.3", "grunt-htmllint": "^0.2.7", "grunt-include-source": "^0.7.1", "grunt-jscs": "^2.7.0", "grunt-newer": "^1.1.1", "grunt-shell": "^1.1.2", + "grunt-usemin": "^3.1.1", "grunt-wiredep": "^2.0.0", "jshint-stylish": "^2.1.0", "load-grunt-configs": "^0.4.3",