Skip to content

Commit 201de63

Browse files
Glinkismichael-ciniawsky
authored andcommitted
feat(index): add interpolation support (loaderUtils.interpolateName) (#21)
1 parent 2923f64 commit 201de63

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ require("exports-loader?file,parse=helpers.parse!./file.js");
2929
require("exports-loader?file!./file.js");
3030
// adds below code to the file's source:
3131
// module.exports = file;
32+
33+
require("exports-loader?[name]!./file.js");
34+
// adds below code to the file's source:
35+
// module.exports = file;
3236
```
3337

3438
<h2 align="center">Maintainers</h2>

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ module.exports = function(content, sourceMap) {
1111
var query = loaderUtils.getOptions(this) || {};
1212
var exports = [];
1313
var keys = Object.keys(query);
14+
// apply name interpolation i.e. substitute strings like [name] or [ext]
15+
for (var i = 0; i < keys.length; i++) {
16+
keys[i] = loaderUtils.interpolateName(this, keys[i], {});
17+
};
1418
if(keys.length == 1 && typeof query[keys[0]] == "boolean") {
1519
exports.push("module.exports = " + keys[0] + ";");
1620
} else {

0 commit comments

Comments
 (0)