adding sourceRoot to minified mapping

v1.18.x
Julian Lam 11 years ago
parent 347d7de25b
commit 1d3aafc08f

@ -13,7 +13,7 @@ var uglifyjs = require('uglify-js'),
}; };
/* Javascript */ /* Javascript */
Minifier.js.minify = function (scripts, minify, callback) { Minifier.js.minify = function (scripts, relativePath, minify, callback) {
var options = {}; var options = {};
scripts = scripts.filter(function(file) { scripts = scripts.filter(function(file) {
@ -23,6 +23,7 @@ Minifier.js.minify = function (scripts, minify, callback) {
if (!minify) { if (!minify) {
options.sourceMapURL = '/nodebb.min.js.map'; options.sourceMapURL = '/nodebb.min.js.map';
options.outSourceMap = 'nodebb.min.js.map'; options.outSourceMap = 'nodebb.min.js.map';
options.sourceRoot = relativePath;
options.mangle = false; options.mangle = false;
options.compress = false; options.compress = false;
options.prefix = 1; options.prefix = 1;
@ -56,7 +57,7 @@ Minifier.js.minify = function (scripts, minify, callback) {
process.on('message', function(payload) { process.on('message', function(payload) {
switch(payload.action) { switch(payload.action) {
case 'js': case 'js':
Minifier.js.minify(payload.scripts, payload.minify, function(data) { Minifier.js.minify(payload.scripts, payload.relativePath, payload.minify, function(data) {
process.stdout.write(data.js); process.stdout.write(data.js);
process.send({ process.send({
type: 'end', type: 'end',

@ -6,6 +6,7 @@ var winston = require('winston'),
async = require('async'), async = require('async'),
_ = require('underscore'), _ = require('underscore'),
os = require('os'), os = require('os'),
nconf = require('nconf'),
plugins = require('../plugins'), plugins = require('../plugins'),
emitter = require('../emitter'), emitter = require('../emitter'),
@ -177,6 +178,7 @@ module.exports = function(Meta) {
Meta.js.prepare(function() { Meta.js.prepare(function() {
minifier.send({ minifier.send({
action: 'js', action: 'js',
relativePath: nconf.get('url') + '/',
minify: minify, minify: minify,
scripts: Meta.js.scripts.all scripts: Meta.js.scripts.all
}); });

Loading…
Cancel
Save