forked from peerigon/modernizr-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (22 loc) · 754 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
"use strict";
var modernizr = require("modernizr");
function wrapOutput(output) {
// Exposing Modernizr as a module.
return "var hadGlobal = 'Modernizr' in window;\n" +
"var oldGlobal = window.Modernizr;\n" +
output + "\n" +
"export default window.Modernizr;\n" +
"if (hadGlobal) { window.Modernizr = oldGlobal; }\n" +
"else { delete window.Modernizr; }";
}
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));
});
};