mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
plugin source mapping fix -- closes #1609
This commit is contained in:
@@ -26,6 +26,24 @@ function sendStylesheet(req, res, next) {
|
||||
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) {
|
||||
app.get('/stylesheet.css', sendStylesheet);
|
||||
app.get('/nodebb.min.js', sendMinifiedJS);
|
||||
@@ -34,5 +52,6 @@ module.exports = function(app, middleware, controllers) {
|
||||
|
||||
if (!minificationEnabled) {
|
||||
app.get('/nodebb.min.js.map', sendSourceMap);
|
||||
setupPluginSourceMapping(app);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user