forked from peerigon/modernizr-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 822 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";
var modernizr = require("modernizr");
function wrapOutput(output) {
// Exposing Modernizr as a module.
return ";(function(window){\n" +
"var hadGlobal = 'Modernizr' in window;\n" +
"var oldGlobal = window.Modernizr;\n" +
output + "\n" +
"module.exports = window.Modernizr;\n" +
"if (hadGlobal) { window.Modernizr = oldGlobal; }\n" +
"else { delete window.Modernizr; }\n" +
"})(window);";
}
module.exports = function (config) {
if (typeof this.cacheable === 'function') {
this.cacheable();
}
var cb = this.async();
// `this.exec` is deprecated
var options = require(this.resourcePath) || {};
modernizr.build(options, function (output) {
cb(null, wrapOutput(output));
});
};