fe88d5c6 by Adam Heath

A bit of refactoring, so that there are now 4 primary phases.

There might be more phases introduced in the future.
1 parent e1ade724
...@@ -708,6 +708,24 @@ module.exports = function (grunt) { ...@@ -708,6 +708,24 @@ module.exports = function (grunt) {
708 } 708 }
709 }); 709 });
710 710
711 var copyList = [];
712 var minifyList = [];
713 var revList = [];
714 var useList = [];
715 grunt.registerTask('do-copy', 'copy files', function() {
716 grunt.task.run(copyList);
717 });
718 grunt.registerTask('do-minify', 'minify files', function() {
719 grunt.task.run(minifyList);
720 });
721 grunt.registerTask('do-rev', 'rev files', function() {
722 if (mpConfig.useRev) {
723 grunt.task.run(revList);
724 }
725 });
726 grunt.registerTask('do-use', 'use files', function() {
727 grunt.task.run(useList);
728 });
711 grunt.registerTask('build', 'build the system', function() { 729 grunt.registerTask('build', 'build the system', function() {
712 var buildList = [ 730 var buildList = [
713 'check', 731 'check',
...@@ -724,59 +742,54 @@ module.exports = function (grunt) { ...@@ -724,59 +742,54 @@ module.exports = function (grunt) {
724 if (mpConfig.punch) { 742 if (mpConfig.punch) {
725 buildList.push('punch:generate'); 743 buildList.push('punch:generate');
726 } 744 }
745 useList.push('usemin:html');
727 buildList.push('useminPrepare'); // html 746 buildList.push('useminPrepare'); // html
728 //buildList.push('usemin:views' 747 //buildList.push('usemin:views'
729 if (mpConfig.bower) { 748 if (mpConfig.bower) {
730 buildList.push('requirejs'); // script 749 buildList.push('requirejs'); // script
731 } 750 }
732 if (mpConfig.css) { 751 if (mpConfig.css) {
733 buildList.push('copy:css'); // css 752 copyList.push('copy:css'); // css
753 minifyList.push('cssmin'); // css
754 revList.push('rev:css'); // css
755 useList.push('usemin:css'); // css
734 } 756 }
735 if (mpConfig.images) { 757 if (mpConfig.images) {
736 var minify = mpConfig.images.options.minify; 758 var minify = mpConfig.images.options.minify;
737 if (minify === undefined || minify) { 759 if (minify === undefined || minify) {
738 buildList.push('imagemin'); // image 760 copyList.push('imagemin'); // image
739 } else { 761 } else {
740 buildList.push('copy:img'); // image 762 copyList.push('copy:img'); // image
741 }
742 buildList.push('svgmin'); // image
743 if (mpConfig.useRev) {
744 buildList.push('rev:img'); // image
745 } 763 }
764 minifyList.push('svgmin'); // image
765 revList.push('rev:img'); // image
746 } 766 }
747 //buildList.push('autoprefixer'); // css 767 //buildList.push('autoprefixer'); // css
748 if (mpConfig.punch) { 768 if (mpConfig.punch) {
749 buildList.push('concat:generated'); // montyPython 769 copyList.push('concat:generated'); // montyPython
750 } 770 }
751 if (mpConfig.css) { 771 if (mpConfig.uglify) {
752 buildList.push('cssmin'); // montyPython 772 minifyList.push('uglify:generated'); // montyPython
753 } 773 }
774 copyList.push('copy:dist');
775 revList.push('rev:dist'); // montyPython
776
777 buildList.push('do-copy');
778 buildList.push('do-minify');
754 //'uglify:dist'); 779 //'uglify:dist');
755 buildList.push('copy:dist');
756 //'modernizr'); 780 //'modernizr');
757 if (mpConfig.uglify) { 781 buildList.push('do-rev');
758 buildList.push('uglify:generated'); // montyPython
759 }
760 if (mpConfig.useRev) {
761 buildList.push('rev:dist'); // montyPython
762 if (mpConfig.css) {
763 buildList.push('rev:css'); // montyPython
764 }
765 }
766 buildList.push('fixRequireConfig'); 782 buildList.push('fixRequireConfig');
767 if (mpConfig.bower) { 783 if (mpConfig.bower) {
768 buildList.push('concat:requirejs'); // montyPython 784 buildList.push('concat:requirejs'); // montyPython
785 if (mpConfig.useRev) {
786 buildList.push('rev:requirejs');
787 }
788 if (mpConfig.uglify) {
789 buildList.push('uglify:montyPython'); // montyPython
790 }
769 } 791 }
770 if (mpConfig.useRev) { 792 buildList.push('do-use');
771 buildList.push('rev:requirejs');
772 }
773 if (mpConfig.bower && mpConfig.uglify) {
774 buildList.push('uglify:montyPython'); // montyPython
775 }
776 buildList.push('usemin:html'); // montyPython
777 if (mpConfig.css) {
778 buildList.push('usemin:css'); // montyPython
779 }
780 buildList.push('htmlmin'); // montyPython 793 buildList.push('htmlmin'); // montyPython
781 buildList.push('deploy'); // montyPython 794 buildList.push('deploy'); // montyPython
782 795
......