Skip to content

Commit b854d61

Browse files
authored
Merge pull request #5439 from plotly/compress-headers
Avoid redundant plotly.js copyright comments in bundles
2 parents f8f08cf + cf4133d commit b854d61

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"browserify": {
5555
"transform": [
5656
"glslify",
57+
"./tasks/compress_headers.js",
5758
"./tasks/compress_attributes.js"
5859
]
5960
},

tasks/compress_headers.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var through = require('through2');
2+
3+
var licenseSrc = require('./util/constants').licenseSrc
4+
.replace(/\//g, '\\/')
5+
.replace(/\*/g, '\\*')
6+
.replace(/\n/g, '[^]');
7+
8+
/**
9+
* Browserify transform that strips redundant plotly.js Copyright comments out
10+
* of the plotly.js bundles
11+
*/
12+
13+
var WHITESPACE_BEFORE = '\\s*';
14+
15+
module.exports = function() {
16+
var allChunks = [];
17+
return through(function(chunk, enc, next) {
18+
allChunks.push(chunk);
19+
next();
20+
}, function(done) {
21+
var str = Buffer.concat(allChunks).toString('utf-8');
22+
this.push(
23+
str.replace(new RegExp(WHITESPACE_BEFORE + licenseSrc, 'g'), '')
24+
);
25+
done();
26+
});
27+
};

0 commit comments

Comments
 (0)