@@ -4,20 +4,22 @@ module.exports = function(grunt) {
4
4
5
5
pkg : grunt . file . readJSON ( 'package.json' ) ,
6
6
7
+ banner : '/**\n' +
8
+ '* Package: <%= pkg.name %> - v<%= pkg.version %> \n' +
9
+ '* Description: <%= pkg.description %> \n' +
10
+ '* Last build: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
11
+ '* @author <%= pkg.author %> \n' +
12
+ '* @license <%= pkg.license %> \n' +
13
+ '*/\n' ,
14
+
7
15
jshint : {
8
16
gruntfile : [ 'Gruntfile.js' ] ,
9
17
scripts : [ 'src/**/*.js' ]
10
18
} ,
11
19
12
20
concat : {
13
21
options : {
14
- banner : '/**\n' +
15
- '* Package: <%= pkg.name %> - v<%= pkg.version %> \n' +
16
- '* Description: <%= pkg.description %> \n' +
17
- '* Last build: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
18
- '* @author <%= pkg.author %> \n' +
19
- '* @license <%= pkg.license %> \n' +
20
- '*/\n'
22
+ banner : '<%= banner %>'
21
23
} ,
22
24
dist : {
23
25
src : [ 'src/<%= pkg.name %>.module.js' , 'src/<%= pkg.name %>.*.js' ] ,
@@ -28,13 +30,7 @@ module.exports = function(grunt) {
28
30
uglify : {
29
31
options : {
30
32
mangle : false ,
31
- banner : '/**\n' +
32
- '* Package: <%= pkg.name %> - v<%= pkg.version %> \n' +
33
- '* Description: <%= pkg.description %> \n' +
34
- '* Last build: <%= grunt.template.today("yyyy-mm-dd") %> \n' +
35
- '* @author <%= pkg.author %> \n' +
36
- '* @license <%= pkg.license %> \n' +
37
- '*/\n'
33
+ banner : '<%= banner %>'
38
34
} ,
39
35
dist : {
40
36
files : {
@@ -73,12 +69,37 @@ module.exports = function(grunt) {
73
69
port : 8080 ,
74
70
open : true ,
75
71
livereload : true ,
72
+ hostname : 'localhost' ,
76
73
base : {
77
74
path : '.' ,
78
75
options : {
79
76
index : 'example/index.html'
80
77
}
81
- }
78
+ } ,
79
+ middleware : function ( connect , options , middlewares ) {
80
+
81
+ var url = require ( 'url' ) ;
82
+
83
+ // inject a custom middleware into the array of default middlewares
84
+ middlewares . unshift ( function ( req , res , next ) {
85
+
86
+ if ( req . url . indexOf ( '/api/test/' ) === - 1 ) return next ( ) ;
87
+
88
+ var value = req . url . replace ( '/api/test/' , '' ) ;
89
+
90
+ if ( value === '[email protected] ' ) {
91
+ res . writeHead ( 200 ) ;
92
+ res . end ( 'ok' ) ;
93
+ return ;
94
+ }
95
+
96
+ res . writeHead ( 200 ) ;
97
+ res . end ( ) ;
98
+
99
+ } ) ;
100
+
101
+ return middlewares ;
102
+ } ,
82
103
}
83
104
}
84
105
}
0 commit comments