modernizr-loader
modernizr-loader copied to clipboard
Compatibility with modernizr-server
Hi,
I just made some middleware to handle fetching modernizr information to the server. It's called modernizr-server. Do you think its possible to change the wrapOutput function while targetting node to something like this? Not to experience with building webpack loaders.
function wrapOutput(output) {
// Exposing Modernizr as a module.
return ";(function(global){\n" +
"var hadGlobal = 'Modernizr' in global;\n" +
"var oldGlobal = global.Modernizr;\n" +
"global.Modernizr = `" + output + "`\n" +
"module.exports = global.Modernizr;\n" +
"if (hadGlobal) { global.Modernizr = oldGlobal; }\n" +
"else { delete global.Modernizr; }\n" +
"})(global);";
}
This would just make expose the modernizr build as a string that modernizr-server would send to the client to be executed.
It would work with modernizr-server like this.
app.use(modernizrServer({
build: Modernizr
}))
app.get('/', function(req, res) {
let Moderizr = req.cookies.modernizr
}
see modernizr-server for more information.