@@ -11,66 +11,26 @@ module.exports = function(grunt) {
11
11
banner : '/* WebUploader <%= pkg.version %> */\n(function( window, undefined ) {\n' ,
12
12
footer : '\n})( this );' ,
13
13
separator : '\n\n' ,
14
- process : function ( src , filepath ) {
15
- return src . replace ( / @ v e r s i o n @ / g, grunt . config . get ( 'pkg.version' ) )
16
- . replace ( / ( ^ | \r \n | \r | \n ) / g, '$1 ' ) ;
17
- } ,
18
-
19
- // 排序,让被依赖的文件移至最上面。
20
- filesFilter : function ( f , files ) {
21
- var cwd = f . cwd || '' ,
22
- ret = [ ] ,
23
- process = function ( file ) {
24
- var fileinfo = path . join ( cwd , file ) ,
25
- str , matches , depends , idx ;
26
-
27
- if ( ! grunt . file . exists ( fileinfo ) ) {
28
- return ;
29
- }
30
-
31
- ret . push ( file ) ;
32
-
33
- str = grunt . file . read ( fileinfo ) ;
34
- matches = str . match ( / @ i m p o r t \s ( .* ?) $ / im) ;
35
- if ( matches ) {
36
- depends = matches [ 1 ]
37
-
38
- // 多个依赖用道号隔开
39
- . split ( / \s * , \s * / g) ;
40
14
41
- idx = ret . indexOf ( file ) ;
42
- [ ] . splice . apply ( ret , [ idx , 0 ] . concat ( depends ) ) ;
43
- depends . forEach ( process ) ;
44
- }
45
-
46
-
47
- } ;
48
- // console.log( files );
49
- files . forEach ( process ) ;
50
- ret = ret . filter ( function ( item , idx , arr ) {
51
- return idx === arr . indexOf ( item ) ;
52
- } ) ;
53
-
54
- return ret ;
15
+ // 调整缩进
16
+ process : function ( src , filepath ) {
17
+ return src . replace ( / ( ^ | \r \n | \r | \n ) / g, '$1 ' ) ;
55
18
}
56
19
} ,
20
+
57
21
all : {
58
22
options : {
59
- process : function ( src , filepath ) {
23
+ process : function ( src ) {
60
24
return src
61
- . replace ( / w e b u p l o a d e r \/ j q - b r i d g e / g, 'jQuery' )
62
- . replace ( / @ v e r s i o n @ / g, grunt . config . get ( 'pkg.version' ) )
63
- . replace ( / ( ^ | \r \n | \r | \n ) / g, '$1 ' ) ;
25
+ // .replace('jQuery', 'jq-bridge')
26
+ . replace ( / ( ^ | \r \n | \r | \n ) / g, '$1 ' ) ;
64
27
}
65
28
} ,
66
29
67
30
cwd : 'src' ,
68
31
69
32
src : [
70
- 'amd.js' ,
71
33
// 'jq-bridge.js',
72
- 'base.js' ,
73
- // 'promise.js',
74
34
75
35
// 把剩余的打包进来。
76
36
'widgets/filepicker.js' ,
@@ -89,28 +49,15 @@ module.exports = function(grunt) {
89
49
options : {
90
50
banner : '/* WebUploader <%= pkg.version %> */\n(function( window, undefined ) {\n' ,
91
51
footer : '\n})( this );\nexports = this.WebUploader;' ,
92
- separator : '\n\n' ,
93
- process : function ( src , filepath ) {
94
- return src
95
- . replace ( / w e b u p l o a d e r \/ j q - b r i d g e / g, 'jQuery' )
96
- . replace ( / @ v e r s i o n @ / g, grunt . config . get ( 'pkg.version' ) )
97
- . replace ( / ( ^ | \r \n | \r | \n ) / g, '$1 ' ) ;
98
- }
99
52
} ,
100
53
101
54
cwd : 'src' ,
102
55
103
56
src : [
104
- 'amd.js' ,
105
- // 'jq-bridge.js',
106
- 'base.js' ,
107
- // 'promise.js',
108
-
109
57
// 把剩余的打包进来。
110
58
'widgets/filepicker.js' ,
111
59
'**/*.js' ,
112
60
113
-
114
61
'!exports.js' ,
115
62
'exports.js'
116
63
] ,
@@ -120,16 +67,35 @@ module.exports = function(grunt) {
120
67
} ,
121
68
122
69
music : {
70
+ cwd : 'src' ,
71
+
72
+ src : [
73
+ 'amd.js' ,
74
+ 'base.js' ,
75
+
76
+ // 把剩余的打包进来。
77
+ 'widgets/filepicker.js' ,
78
+ 'widgets/filednd.js' ,
79
+ 'widgets/queue.js' ,
80
+ 'widgets/runtime.js' ,
81
+ 'widgets/upload.js' ,
82
+
83
+ 'runtime/html5/blob.js' ,
84
+ 'runtime/html5/transport.js' ,
85
+ 'runtime/html5/filepicker.js' ,
86
+ 'runtime/html5/dnd.js' ,
87
+
88
+ '!exports.js' ,
89
+ 'exports.js'
90
+ ] ,
91
+
92
+ dest : 'examples/music/webuploader.js'
93
+ } ,
94
+
95
+ wenku : {
123
96
options : {
124
97
banner : '/* WebUploader <%= pkg.version %> */\n(function( window, undefined ) {\n' ,
125
- footer : '\n})( this );' ,
126
- separator : '\n\n' ,
127
- process : function ( src , filepath ) {
128
- return src
129
- . replace ( / w e b u p l o a d e r \/ j q - b r i d g e / g, 'jQuery' )
130
- . replace ( / @ v e r s i o n @ / g, grunt . config . get ( 'pkg.version' ) )
131
- . replace ( / ( ^ | \r \n | \r | \n ) / g, '$1 ' ) ;
132
- }
98
+ footer : '\n})( this );exports = WebUploader;'
133
99
} ,
134
100
135
101
cwd : 'src' ,
@@ -158,7 +124,7 @@ module.exports = function(grunt) {
158
124
] ,
159
125
160
126
161
- dest : 'examples/music /webuploader.js'
127
+ dest : '/Users/liaoxuezhi/www/wenku/common/static/common/ui/js_core/upload /webuploader.js'
162
128
}
163
129
164
130
@@ -186,7 +152,7 @@ module.exports = function(grunt) {
186
152
187
153
concat : {
188
154
files : [ 'src/**/*.js' , 'Gruntfile.js' ] ,
189
- tasks : [ 'concat:music ' ] ,
155
+ tasks : [ 'concat:wenku ' ] ,
190
156
}
191
157
} ,
192
158
@@ -210,9 +176,6 @@ module.exports = function(grunt) {
210
176
}
211
177
} ) ;
212
178
213
- // 加载build目录下的所有task
214
- // grunt.loadTasks( 'tasks' );
215
-
216
179
// 负责报告文件大小
217
180
grunt . loadNpmTasks ( 'grunt-size' ) ;
218
181
@@ -223,7 +186,7 @@ module.exports = function(grunt) {
223
186
grunt . loadNpmTasks ( 'grunt-contrib-watch' ) ;
224
187
225
188
// 加载build目录下的所有task
226
- grunt . loadTasks ( 'tasks' ) ;
189
+ grunt . loadTasks ( 'build/ tasks' ) ;
227
190
228
191
// Default task(s).
229
192
grunt . registerTask ( 'default' , [ 'jsbint:all' , 'concat:all' ] ) ;
0 commit comments