Skip to content

Commit 7d0145a

Browse files
committed
make only minified with sourcemap
1 parent 0869970 commit 7d0145a

File tree

4 files changed

+44
-34
lines changed

4 files changed

+44
-34
lines changed

tasks/partial_bundle.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ if(process.argv.length > 2) {
6262

6363
name: out,
6464
index: path.join(constants.pathToLib, 'index-' + out + '.js'),
65-
sourceMap: path.join(constants.pathToDist, 'plotly-' + out + '.js.map'),
66-
dist: path.join(constants.pathToDist, 'plotly-' + out + '.js'),
65+
sourceMap: path.join(constants.pathToDist, 'plotly-' + out + '.min.js.map'),
6766
distMin: path.join(constants.pathToDist, 'plotly-' + out + '.min.js')
6867
};
6968

tasks/util/browserify_wrapper.js

+33-18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var strictD3 = require('./strict_d3');
1919
* - standalone {string}
2020
* - debug {boolean} [optional]
2121
* Additional option:
22+
* - pathToSourceMap {string} path to destination source map
2223
* - pathToMinBundle {string} path to destination minified bundle
2324
* - noCompress {boolean} skip attribute meta compression?
2425
* @param {function} cb callback
@@ -62,26 +63,40 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {
6263
});
6364

6465
if(pathToMinBundle) {
65-
bundleStream
66-
.pipe(applyDerequire())
67-
.pipe(minify(constants.uglifyOptions))
68-
.pipe(fs.createWriteStream(pathToMinBundle))
69-
.on('finish', function() {
70-
logger(pathToMinBundle);
71-
done();
72-
});
66+
var minifyOpts = {
67+
ecma: 5,
68+
mangle: true,
69+
output: {
70+
beautify: false,
71+
ascii_only: true
72+
},
73+
74+
sourceMap: !!sourceMap
75+
};
76+
77+
if(sourceMap) {
78+
bundleStream
79+
.pipe(applyDerequire())
80+
.pipe(minify(minifyOpts))
81+
.pipe(exorcist(sourceMap))
82+
.pipe(fs.createWriteStream(pathToMinBundle))
83+
.on('finish', function() {
84+
logger(pathToMinBundle);
85+
done();
86+
});
87+
} else {
88+
bundleStream
89+
.pipe(applyDerequire())
90+
.pipe(minify(minifyOpts))
91+
.pipe(fs.createWriteStream(pathToMinBundle))
92+
.on('finish', function() {
93+
logger(pathToMinBundle);
94+
done();
95+
});
96+
}
7397
}
7498

75-
if(sourceMap) {
76-
bundleStream
77-
.pipe(applyDerequire())
78-
.pipe(exorcist(sourceMap))
79-
.pipe(fs.createWriteStream(pathToBundle))
80-
.on('finish', function() {
81-
logger(pathToBundle);
82-
done();
83-
});
84-
} else {
99+
if(pathToBundle) {
85100
bundleStream
86101
.pipe(applyDerequire())
87102
.pipe(fs.createWriteStream(pathToBundle))

tasks/util/constants.js

-11
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,6 @@ module.exports = {
217217
testContainerUrl: 'http://localhost:9010/',
218218
testContainerHome: '/var/www/streambed/image_server/plotly.js',
219219

220-
uglifyOptions: {
221-
ecma: 5,
222-
mangle: true,
223-
output: {
224-
beautify: false,
225-
ascii_only: true
226-
},
227-
228-
sourceMap: false
229-
},
230-
231220
licenseDist: [
232221
'/**',
233222
'* plotly.js v' + pkg.version,

tasks/util/wrap_locale.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ var path = require('path');
44
var minify = require('minify-stream');
55
var intoStream = require('into-stream');
66

7-
var constants = require('./constants');
8-
97
var prefix = 'var locale=';
108
var suffix = ';if(typeof Plotly === \'undefined\') {window.PlotlyLocales = window.PlotlyLocales || []; window.PlotlyLocales.push(locale);} else {Plotly.register(locale);}';
119

@@ -26,7 +24,16 @@ module.exports = function wrapLocale(pathToInput, pathToOutput) {
2624
var rawOut = prefix + data.substr(moduleStart, moduleEnd - moduleStart) + suffix;
2725

2826
intoStream(rawOut)
29-
.pipe(minify(constants.uglifyOptions))
27+
.pipe(minify({
28+
ecma: 5,
29+
mangle: true,
30+
output: {
31+
beautify: false,
32+
ascii_only: true
33+
},
34+
35+
sourceMap: false
36+
}))
3037
.pipe(fs.createWriteStream(pathToOutput))
3138
.on('finish', function() {
3239
logger(pathToOutput);

0 commit comments

Comments
 (0)