Skip to content

Commit ff25210

Browse files
committed
Merge pull request #250 from azakus/master
Recursive build for polymer
2 parents b4f9720 + 00ee2b7 commit ff25210

File tree

4 files changed

+69
-61
lines changed

4 files changed

+69
-61
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ local.json
55
polymer.min*
66
polymer.sandbox*
77
polymer.native*
8+
polymer.concat*

build.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
"../platform/build.json",
3+
"src/polymer.js",
4+
"src/boot.js",
5+
"src/lib/lang.js",
6+
"src/lib/job.js",
7+
"src/lib/dom.js",
8+
"src/lib/super.js",
9+
"src/lib/deserialize.js",
10+
"src/api.js",
11+
"src/instance/utils.js",
12+
"src/instance/events.js",
13+
"src/instance/attributes.js",
14+
"src/instance/properties.js",
15+
"src/instance/mdv.js",
16+
"src/instance/base.js",
17+
"src/instance/styles.js",
18+
"src/declaration/path.js",
19+
"src/declaration/styles.js",
20+
"src/declaration/events.js",
21+
"src/declaration/properties.js",
22+
"src/declaration/attributes.js",
23+
"src/declaration/prototype.js",
24+
"src/declaration/polymer-element.js",
25+
"src/deprecated.js"
26+
]

gruntfile.js

+39-59
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,26 @@
55
*/
66
module.exports = function(grunt) {
77
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-
];
158

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');
4728

4829
// karma setup
4930
var browsers;
@@ -81,6 +62,16 @@ module.exports = function(grunt) {
8162
browsers: browsers
8263
}
8364
},
65+
concat_sourcemap: {
66+
Polymer: {
67+
options: {
68+
sourcesContent: true
69+
},
70+
files: {
71+
'polymer.concat.js': Polymer
72+
}
73+
}
74+
},
8475
uglify: {
8576
options: {
8677
banner: banner,
@@ -89,27 +80,11 @@ module.exports = function(grunt) {
8980
Polymer: {
9081
options: {
9182
sourceMap: 'polymer.min.js.map',
83+
sourceMapIn: 'polymer.concat.js.map'
9284
//mangle: false, beautify: true, compress: false
9385
},
9486
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'
11388
}
11489
}
11590
},
@@ -150,8 +125,6 @@ module.exports = function(grunt) {
150125
dest: 'build.log',
151126
src: [
152127
'polymer.min.js',
153-
'polymer.native.min.js',
154-
'polymer.sandbox.min.js'
155128
]
156129
}
157130
},
@@ -161,11 +134,18 @@ module.exports = function(grunt) {
161134
// plugins
162135
grunt.loadNpmTasks('grunt-contrib-uglify');
163136
grunt.loadNpmTasks('grunt-contrib-yuidoc');
137+
grunt.loadNpmTasks('grunt-concat-sourcemap');
164138
grunt.loadNpmTasks('grunt-karma');
165139
grunt.loadNpmTasks('grunt-audit');
166140

167141
// 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']);
169149
grunt.registerTask('minify', ['uglify']);
170150
grunt.registerTask('docs', ['yuidoc']);
171151
grunt.registerTask('test', ['karma:polymer']);

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"devDependencies": {
55
"mocha": "*",
66
"chai": "*",
7-
"grunt": "*",
7+
"grunt": "~0.4.1",
88
"grunt-contrib-uglify": "*",
99
"grunt-contrib-yuidoc": "*",
1010
"grunt-karma": "*",
1111
"karma-mocha": "*",
1212
"karma-ie-launcher": "*",
1313
"karma-script-launcher": "*",
1414
"karma-crbot-reporter": "*",
15-
"grunt-audit": "~0.0.1"
15+
"grunt-audit": "~0.0.1",
16+
"grunt-concat-sourcemap": "~0.3.0"
1617
}
1718
}

0 commit comments

Comments
 (0)