-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
30 lines (28 loc) · 1.07 KB
/
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
var loaderUtils = require("loader-utils");
module.exports = function(source, map) {
this.callback(null, source, map);
};
module.exports.pitch = function(remainingRequest) {
this.cacheable();
return `
// classnames-loader: automatically bind css-modules to classnames
function interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
var classNames = require(${loaderUtils.stringifyRequest(this, '!' + require.resolve('classnames/bind'))});
var locals = interopRequireDefault(require(${loaderUtils.stringifyRequest(this, '!!' + remainingRequest)})).default;
var css = classNames.bind(locals);
for (var style in locals) {
if (!locals.hasOwnProperty(style)) {
continue;
}
if (typeof Object.defineProperty === 'function') {
Object.defineProperty(css, style, {value: locals[style]});
}
else {
css[style] = locals[style];
}
}
module.exports = css;
`;
};