updated dependencies to use latest UglifyJS2, instead of my year-old fork

v1.18.x
Julian Lam 10 years ago
parent 1d4efaee68
commit 2d70733fa5

@ -30,9 +30,10 @@ Minifier.js.minify = function (scripts, minify, callback) {
process.on('message', function(payload) {
switch(payload.action) {
case 'js':
Minifier.js.minify(payload.scripts, payload.minify, function(minified) {
Minifier.js.minify(payload.scripts, payload.minify, function(minified/*, sourceMap*/) {
process.send({
type: 'end',
// sourceMap: sourceMap,
minified: minified
});
});
@ -41,8 +42,11 @@ process.on('message', function(payload) {
});
function minifyScripts(scripts, callback) {
// The portions of code involving the source map are commented out as they're broken in UglifyJS2
// Follow along here: https://github.com/mishoo/UglifyJS2/issues/700
try {
var minified = uglifyjs.minify(scripts, {
// outSourceMap: "nodebb.min.js.map",
compress: false
}),
hasher = crypto.createHash('md5'),
@ -56,7 +60,7 @@ function minifyScripts(scripts, callback) {
payload: hash.slice(0, 8)
});
callback(minified.code);
callback(minified.code/*, minified.map*/);
} catch(err) {
process.send({
type: 'error',

@ -69,7 +69,7 @@
"string": "^3.0.0",
"templates.js": "^0.2.6",
"touch": "0.0.3",
"uglify-js": "git+https://github.com/julianlam/UglifyJS2.git",
"uglify-js": "^2.4.23",
"underscore": "~1.8.3",
"underscore.deep": "^0.5.1",
"validator": "^3.30.0",

@ -141,6 +141,7 @@ module.exports = function(Meta) {
switch(message.type) {
case 'end':
Meta.js.cache = message.minified;
Meta.js.map = message.sourceMap;
onComplete();
break;
case 'hash':

@ -8,6 +8,16 @@ function sendMinifiedJS(req, res, next) {
res.type('text/javascript').send(meta.js.cache);
}
// The portions of code involving the source map are commented out as they're broken in UglifyJS2
// Follow along here: https://github.com/mishoo/UglifyJS2/issues/700
// function sendJSSourceMap(req, res) {
// if (meta.js.hasOwnProperty('map')) {
// res.type('application/json').send(meta.js.map);
// } else {
// res.redirect(404);
// }
// };
function sendStylesheet(req, res, next) {
res.type('text/css').status(200).send(meta.css.cache);
}
@ -20,6 +30,7 @@ module.exports = function(app, middleware, controllers) {
app.get('/stylesheet.css', middleware.addExpiresHeaders, sendStylesheet);
app.get('/admin.css', middleware.addExpiresHeaders, sendACPStylesheet);
app.get('/nodebb.min.js', middleware.addExpiresHeaders, sendMinifiedJS);
// app.get('/nodebb.min.js.map', middleware.addExpiresHeaders, sendJSSourceMap);
app.get('/sitemap.xml', controllers.sitemap);
app.get('/robots.txt', controllers.robots);
app.get('/css/previews/:theme', controllers.admin.themes.get);

Loading…
Cancel
Save