-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpolymer-build.js
More file actions
35 lines (29 loc) · 930 Bytes
/
polymer-build.js
File metadata and controls
35 lines (29 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const build = require('polymer-build');
const merge = require('merge-stream');
const path = require('path');
const rename = require('gulp-rename');
const size = require('gulp-size');
/**
* Executes the polymer-build, which a.o. vulcanizes and minifies the HTML
*
* @param {Object} config Content of polymer.json
* @returns
*/
function polymerBuild(config) {
const skipRootFolder = function(file) {
const rootFolder = config.root || '.';
file.dirname = path.relative(rootFolder, file.dirname);
};
const project = new build.PolymerProject(config);
const bundler = project.bundler({
// XXX: sourcemaps makes V8 run out of memory
sourcemaps: false,
stripComments: true,
}).on('error', e => console.error(e));
return merge(project.sources(), project.dependencies())
.pipe(bundler)
.pipe(size({title: 'polymer-bundler'}))
.pipe(rename(skipRootFolder));
};
module.exports = polymerBuild;