plugin source mapping fix -- closes #1609

v1.18.x
Julian Lam 11 years ago
parent 53f5dbfeca
commit b553d44107

@ -26,6 +26,24 @@ function sendStylesheet(req, res, next) {
res.type('text/css').send(200, meta.css.cache); res.type('text/css').send(200, meta.css.cache);
} }
function setupPluginSourceMapping(app) {
/*
These mappings are utilised by the source map file, as client-side
scripts defined in `scripts` in plugin.json are not normally
served to the end-user. These mappings are only accessible via
development mode (`./nodebb dev`)
*/
var routes = plugins.clientScripts,
mapping;
routes.forEach(function(route) {
mapping = '/' + route.split('/').slice(7).join('/');
app.get(mapping, function(req, res) {
res.type('text/javascript').sendfile(route);
});
});
}
module.exports = function(app, middleware, controllers) { module.exports = function(app, middleware, controllers) {
app.get('/stylesheet.css', sendStylesheet); app.get('/stylesheet.css', sendStylesheet);
app.get('/nodebb.min.js', sendMinifiedJS); app.get('/nodebb.min.js', sendMinifiedJS);
@ -34,5 +52,6 @@ module.exports = function(app, middleware, controllers) {
if (!minificationEnabled) { if (!minificationEnabled) {
app.get('/nodebb.min.js.map', sendSourceMap); app.get('/nodebb.min.js.map', sendSourceMap);
setupPluginSourceMapping(app);
} }
}; };

Loading…
Cancel
Save