brunt build dist

James Peret 8 years ago
parent
commit
c5de458d94
7 changed files with 100 additions and 31 deletions
  1. 71 14
      Gruntfile.js
  2. 0 0
      app/data.json
  3. 18 12
      app/index.html
  4. 1 1
      app/scripts/controllers/navigation.js
  5. 1 1
      app/scripts/services/data.js
  6. 1 1
      bower.json
  7. 8 2
      package.json

+ 71 - 14
Gruntfile.js

@@ -21,32 +21,60 @@ module.exports = function(grunt) {
21 21
       },
22 22
       dist: {
23 23
         // the files to concatenate
24
-        src: ['src/**/*.js'],
24
+        src: ['app/scripts/*.js', 'app/scripts/**/*.js'],
25 25
         // the location of the resulting JS file
26
-        dest: 'dist/<%= pkg.name %>.js'
26
+        dest: 'dist/js/app.js'
27 27
       }
28 28
     },
29 29
     uglify: {
30 30
       options: {
31 31
         // the banner is inserted at the top of the output
32
-        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
32
+        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
33
+        mangle: false
33 34
       },
34 35
       dist: {
35 36
         files: {
36
-          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
37
+          'dist/js/app.min.js': ['<%= concat.dist.dest %>']
37 38
         }
38 39
       }
39 40
     },
41
+    cssmin: {
42
+     options: {
43
+       banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
44
+       shorthandCompacting: false,
45
+       roundingPrecision: -1
46
+     },
47
+     target: {
48
+       files: {
49
+         'dist/css/styles.css': ['app/styles/*.css']
50
+       }
51
+     }
52
+    },
40 53
     qunit: {
41 54
       files: ['test/**/*.html']
42 55
     },
56
+    bower: {
57
+      dist: {
58
+        dest: 'dist/lib/'
59
+      }
60
+    },
61
+    copy: {
62
+      dist: {
63
+        files: [
64
+          {src: ['app/index.html'], dest: 'dist/index.html', filter: 'isFile'},
65
+          {src: ['app/data.json'], dest: 'dist/data.json', filter: 'isFile'},
66
+          {expand: true, flatten: false, cwd: 'app/views/', src: ['**'], dest: 'dist/views/', filter: 'isFile'},
67
+          {expand: true, flatten: false, cwd: 'app/content/', src: ['**'], dest: 'dist/content/', filter: 'isFile'}
68
+        ]
69
+      }
70
+    },
43 71
     wiredep: {
44 72
       task: {
45 73
         // Point to the files that should be updated when
46 74
         // you run `grunt wiredep`
47 75
         src: [
48 76
           'app/*.html',
49
-		'app/views/**/*.html',   // .html support...
77
+		      'app/views/**/*.html',   // .html support...
50 78
           'app/views/**/*.jade',   // .jade support...
51 79
           'app/styles/main.scss',  // .scss & .sass support...
52 80
           'app/config.yml'         // and .yml & .yaml support out of the box!
@@ -57,12 +85,27 @@ module.exports = function(grunt) {
57 85
           // https://github.com/taptapship/wiredep#configuration
58 86
         }
59 87
       }
60
-     },
61
-	serve: {
62
-	    options: {
63
-	        port: 8000,
64
-	    }
65
-	}
88
+    },
89
+  	serve: {
90
+  	    options: {
91
+  	        port: 8000,
92
+  	    },
93
+        dist: {
94
+          path: '/dist'
95
+        }
96
+  	},
97
+    useminPrepare: {
98
+      html: 'dist/index.html',
99
+      options: {
100
+        dest: 'dist/'
101
+      }
102
+    },
103
+    usemin: {
104
+      html: 'dist/index.html',
105
+      options: {
106
+        assetsDirs: ['dist/js', 'dist/css', 'dist/content']
107
+      }
108
+    }
66 109
   });
67 110
 
68 111
   grunt.loadNpmTasks('grunt-contrib-uglify');
@@ -72,11 +115,25 @@ module.exports = function(grunt) {
72 115
   grunt.loadNpmTasks('grunt-contrib-concat');
73 116
   grunt.loadNpmTasks('grunt-wiredep');
74 117
   grunt.loadNpmTasks('grunt-serve');
118
+  grunt.loadNpmTasks('grunt-contrib-cssmin');
119
+  grunt.loadNpmTasks('grunt-bower');
120
+  grunt.loadNpmTasks('grunt-contrib-copy');
121
+  //grunt.loadNpmTasks('grunt-filerev');
122
+  grunt.loadNpmTasks('grunt-usemin');
123
+
124
+
75 125
 
76
-  // this would be run by typing "grunt test" on the command line
77 126
   grunt.registerTask('test', ['jshint', 'qunit']);
127
+  grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'cssmin', 'wiredep' ]);
128
+  grunt.registerTask('deploy', ['jshint', 'bower', 'concat', 'uglify', 'cssmin', 'copy' ]);
78 129
 
79
-  // the default task can be run just by typing "grunt" on the command line
80
-  grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'wiredep']);
130
+  grunt.registerTask('build', [
131
+    'copy',
132
+    'useminPrepare',
133
+    'concat:generated',
134
+    'uglify:generated',
135
+    'usemin',
136
+    'cssmin:target'
137
+  ]);
81 138
 
82 139
 };

app/scripts/data.json → app/data.json


+ 18 - 12
app/index.html

@@ -6,14 +6,18 @@
6 6
     <meta name="description" content="">
7 7
     <meta name="viewport" content="width=device-width">
8 8
 
9
+    <!-- build:css css/styles.css -->
9 10
 		<link rel="stylesheet" href="styles/main.css">
10 11
     <link rel="stylesheet" href="styles/slider.css">
12
+    <!-- endbuild -->
11 13
 
14
+    <!-- build:js js/lib.js -->
12 15
 		<!-- bower:js -->
13 16
 		<script src="../bower_components/jQuery/dist/jquery.js"></script>
14 17
 		<script src="../bower_components/angular/angular.js"></script>
15
-		<script src="../bower_components/famous-angular/dist/famous-angular.min.js"></script>
18
+		<script src="../bower_components/famous-angular/dist/famous-angular.js"></script>
16 19
     <script src="../bower_components/famous/dist/famous-global.min.js"></script>
20
+		<script src="../bower_components/requirejs/require.js"></script>
17 21
 		<script src="../bower_components/angular-animate/angular-animate.js"></script>
18 22
 		<script src="../bower_components/angular-cookies/angular-cookies.js"></script>
19 23
 		<script src="../bower_components/angular-resource/angular-resource.js"></script>
@@ -25,18 +29,20 @@
25 29
 		<script src="../bower_components/angular-ui-router/release/angular-ui-router.js"></script>
26 30
 		<script src="../bower_components/angular-youtube-mb/src/angular-youtube-embed.js"></script>
27 31
 		<!-- endbower -->
32
+    <!-- endbuild -->
28 33
 
29
-		<script src="scripts/app.js"></script>
30
-    <script src="scripts/controllers/index.js"></script>
31
-    <script src="scripts/controllers/background.js"></script>
32
-    <script src="scripts/controllers/navigation.js"></script>
33
-    <script src="scripts/controllers/slideshow.js"></script>
34
-    <script src="scripts/controllers/page.js"></script>
35
-    <script src="scripts/controllers/video.js"></script>
36
-    <script src="scripts/directives/wallop-slider.js"></script>
37
-    <script src="scripts/services/data.js"></script>
38
-    <script src="scripts/services/getController.js"></script>
39
-
34
+    <!-- build:js js/app.js -->
35
+		<script src="../app/scripts/app.js"></script>
36
+    <script src="../app/scripts/controllers/index.js"></script>
37
+    <script src="../app/scripts/controllers/background.js"></script>
38
+    <script src="../app/scripts/controllers/navigation.js"></script>
39
+    <script src="../app/scripts/controllers/slideshow.js"></script>
40
+    <script src="../app/scripts/controllers/page.js"></script>
41
+    <script src="../app/scripts/controllers/video.js"></script>
42
+    <script src="../app/scripts/directives/wallop-slider.js"></script>
43
+    <script src="../app/scripts/services/data.js"></script>
44
+    <script src="../app/scripts/services/getController.js"></script>
45
+    <!-- endbuild -->
40 46
 
41 47
 
42 48
 </head>

+ 1 - 1
app/scripts/controllers/navigation.js

@@ -22,7 +22,7 @@ angular.module('goApp.navigation', ['famous.angular', 'ngRoute', 'ngFx', 'ngAnim
22 22
 
23 23
     $http({
24 24
       method: 'GET',
25
-      url: 'scripts/data.json'
25
+      url: 'data.json'
26 26
     }).success(function(data) {
27 27
       $timeout(function(){
28 28
         $scope.navigation = data.navigation;

+ 1 - 1
app/scripts/services/data.js

@@ -10,7 +10,7 @@ angular.module('goApp.data', [])
10 10
 
11 11
   $http({
12 12
     method: 'GET',
13
-    url: 'scripts/data.json'
13
+    url: 'data.json'
14 14
   }).success(function(json_data) {
15 15
     data = json_data;
16 16
     data_loaded = true;

+ 1 - 1
bower.json

@@ -1,5 +1,5 @@
1 1
 {
2
-  "name": "famous-angular",
2
+  "name": "app",
3 3
   "version": "0.1.0",
4 4
   "authors": [
5 5
     "James Peret <james.peret@gmail.com>"

+ 8 - 2
package.json

@@ -3,13 +3,19 @@
3 3
   "version": "0.1.0",
4 4
   "devDependencies": {
5 5
     "grunt": "~0.4.5",
6
+    "grunt-bower": "^0.19.0",
6 7
     "grunt-contrib-concat": "^0.5.1",
8
+    "grunt-contrib-copy": "^0.8.0",
9
+    "grunt-contrib-cssmin": "^0.12.3",
7 10
     "grunt-contrib-jshint": "~0.10.0",
8 11
     "grunt-contrib-nodeunit": "~0.4.1",
9 12
     "grunt-contrib-qunit": "^0.7.0",
10
-    "grunt-contrib-uglify": "~0.5.0",
13
+    "grunt-contrib-uglify": "^0.9.1",
11 14
     "grunt-contrib-watch": "^0.6.1",
15
+    "grunt-filerev": "^2.3.1",
12 16
     "grunt-serve": "^0.1.6",
13
-    "grunt-wiredep": "^2.0.0"
17
+    "grunt-usemin": "^3.0.0",
18
+    "grunt-wiredep": "^2.0.0",
19
+    "jshint-stylish": "^2.0.1"
14 20
   }
15 21
 }