5
5
*/
6
6
module . exports = function ( grunt ) {
7
7
var banner = [ grunt . file . read ( 'LICENSE' ) , '// @version ' + grunt . file . readJSON ( 'package.json' ) . version , '' ] . join ( grunt . util . linefeed ) ;
8
- Platform = [
9
- '../platform/platform.min.js'
10
- ] ;
11
-
12
- PlatformNative = [
13
- '../platform/platform.native.min.js'
14
- ] ;
15
8
16
- PlatformSandbox = [
17
- '../platform/platform.sandbox.min.js'
18
- ] ;
19
-
20
- Polymer = [
21
- "polymer.js" ,
22
- "boot.js" ,
23
- "lib/lang.js" ,
24
- "lib/job.js" ,
25
- "lib/dom.js" ,
26
- "lib/super.js" ,
27
- "lib/deserialize.js" ,
28
- "api.js" ,
29
- "instance/utils.js" ,
30
- "instance/events.js" ,
31
- "instance/attributes.js" ,
32
- "instance/properties.js" ,
33
- "instance/mdv.js" ,
34
- "instance/base.js" ,
35
- "instance/styles.js" ,
36
- "declaration/path.js" ,
37
- "declaration/styles.js" ,
38
- "declaration/events.js" ,
39
- "declaration/properties.js" ,
40
- "declaration/attributes.js" ,
41
- "declaration/prototype.js" ,
42
- "declaration/polymer-element.js" ,
43
- "deprecated.js"
44
- ] . map ( function ( n ) {
45
- return "src/" + n ;
46
- } ) ;
9
+ // recursive module builder
10
+ var path = require ( 'path' ) ;
11
+ function readManifest ( filename , modules ) {
12
+ modules = modules || [ ] ;
13
+ var lines = grunt . file . readJSON ( filename ) ;
14
+ var dir = path . dirname ( filename ) ;
15
+ lines . forEach ( function ( line ) {
16
+ var fullpath = path . join ( dir , line ) ;
17
+ if ( line . slice ( - 5 ) == '.json' ) {
18
+ // recurse
19
+ readManifest ( fullpath , modules ) ;
20
+ } else {
21
+ modules . push ( fullpath ) ;
22
+ }
23
+ } ) ;
24
+ return modules ;
25
+ }
26
+
27
+ Polymer = readManifest ( 'build.json' ) ;
47
28
48
29
// karma setup
49
30
var browsers ;
@@ -81,6 +62,16 @@ module.exports = function(grunt) {
81
62
browsers : browsers
82
63
}
83
64
} ,
65
+ concat_sourcemap : {
66
+ Polymer : {
67
+ options : {
68
+ sourcesContent : true
69
+ } ,
70
+ files : {
71
+ 'polymer.concat.js' : Polymer
72
+ }
73
+ }
74
+ } ,
84
75
uglify : {
85
76
options : {
86
77
banner : banner ,
@@ -89,27 +80,11 @@ module.exports = function(grunt) {
89
80
Polymer : {
90
81
options : {
91
82
sourceMap : 'polymer.min.js.map' ,
83
+ sourceMapIn : 'polymer.concat.js.map'
92
84
//mangle: false, beautify: true, compress: false
93
85
} ,
94
86
files : {
95
- 'polymer.min.js' : [ ] . concat ( Platform , Polymer )
96
- }
97
- } ,
98
- PolymerNative : {
99
- options : {
100
- sourceMap : 'polymer.native.min.js.map'
101
- } ,
102
- files : {
103
- 'polymer.native.min.js' : [ ] . concat ( PlatformNative , Polymer )
104
- }
105
- } ,
106
- PolymerSandbox : {
107
- options : {
108
- sourceMap : 'polymer.sandbox.min.js.map' ,
109
- //mangle: false, beautify: true, compress: false
110
- } ,
111
- files : {
112
- 'polymer.sandbox.min.js' : [ ] . concat ( PlatformSandbox , Polymer )
87
+ 'polymer.min.js' : 'polymer.concat.js'
113
88
}
114
89
}
115
90
} ,
@@ -150,8 +125,6 @@ module.exports = function(grunt) {
150
125
dest : 'build.log' ,
151
126
src : [
152
127
'polymer.min.js' ,
153
- 'polymer.native.min.js' ,
154
- 'polymer.sandbox.min.js'
155
128
]
156
129
}
157
130
} ,
@@ -161,11 +134,18 @@ module.exports = function(grunt) {
161
134
// plugins
162
135
grunt . loadNpmTasks ( 'grunt-contrib-uglify' ) ;
163
136
grunt . loadNpmTasks ( 'grunt-contrib-yuidoc' ) ;
137
+ grunt . loadNpmTasks ( 'grunt-concat-sourcemap' ) ;
164
138
grunt . loadNpmTasks ( 'grunt-karma' ) ;
165
139
grunt . loadNpmTasks ( 'grunt-audit' ) ;
166
140
167
141
// tasks
168
- grunt . registerTask ( 'default' , [ 'uglify' , 'audit' ] ) ;
142
+ grunt . registerTask ( 'sourcemap_copy' , 'Copy sourcesContent between sourcemaps' , function ( source , dest ) {
143
+ var sourceMap = grunt . file . readJSON ( source ) ;
144
+ var destMap = grunt . file . readJSON ( dest ) ;
145
+ destMap . sourcesContent = sourceMap . sourcesContent ;
146
+ grunt . file . write ( dest , JSON . stringify ( destMap ) ) ;
147
+ } ) ;
148
+ grunt . registerTask ( 'default' , [ 'concat_sourcemap' , 'uglify' , 'sourcemap_copy:polymer.concat.js.map:polymer.min.js.map' , 'audit' ] ) ;
169
149
grunt . registerTask ( 'minify' , [ 'uglify' ] ) ;
170
150
grunt . registerTask ( 'docs' , [ 'yuidoc' ] ) ;
171
151
grunt . registerTask ( 'test' , [ 'karma:polymer' ] ) ;
0 commit comments