mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-31 03:36:51 +02:00
source map support, first pass
This commit is contained in:
@@ -300,7 +300,8 @@ var fs = require('fs'),
|
||||
minifier.on('message', function(payload) {
|
||||
if (payload.action !== 'error') {
|
||||
winston.info('[meta/js] Compilation complete');
|
||||
Meta.js.cache = payload.data;
|
||||
Meta.js.cache = payload.data.js;
|
||||
Meta.js.map = payload.data.map;
|
||||
minifier.kill();
|
||||
} else {
|
||||
winston.error('[meta/js] Could not compile client-side scripts!');
|
||||
@@ -312,7 +313,8 @@ var fs = require('fs'),
|
||||
|
||||
this.prepare(function() {
|
||||
minifier.send({
|
||||
action: minify ? 'js.minify' : 'js.concatenate',
|
||||
action: 'js',
|
||||
minify: minify,
|
||||
scripts: Meta.js.scripts
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,18 +11,28 @@ var path = require('path'),
|
||||
|
||||
|
||||
function sendMinifiedJS(req, res, next) {
|
||||
if (!minificationEnabled) {
|
||||
res.set('X-SourceMap', '/nodebb.min.js.map');
|
||||
}
|
||||
|
||||
return res.type('text/javascript').send(meta.js.cache);
|
||||
}
|
||||
|
||||
function sendSourceMap(req, res) {
|
||||
return res.type('application/json').send(meta.js.map);
|
||||
}
|
||||
|
||||
function sendStylesheet(req, res, next) {
|
||||
res.type('text/css').send(200, meta.css.cache);
|
||||
}
|
||||
|
||||
module.exports = function(app, middleware, controllers) {
|
||||
minificationEnabled = app.enabled('minification');
|
||||
|
||||
app.get('/stylesheet.css', sendStylesheet);
|
||||
app.get('/nodebb.min.js', sendMinifiedJS);
|
||||
app.get('/sitemap.xml', controllers.sitemap);
|
||||
app.get('/robots.txt', controllers.robots);
|
||||
|
||||
if (!minificationEnabled) {
|
||||
app.get('/nodebb.min.js.map', sendSourceMap);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user