Skip to content

Commit b5fdee5

Browse files
author
Johan Persson
committed
Added support for passing options to the DtsCreator.
1 parent 37d97de commit b5fdee5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
var DtsCreator = require('typed-css-modules');
2-
3-
var creator = new DtsCreator();
2+
var loaderUtils = require('loader-utils');
3+
var objectAssign = require('object-assign');
44

55
module.exports = function(source, map) {
66
this.cacheable && this.cacheable();
77
var callback = this.async();
8-
8+
9+
// Pass on query parameters as an options object to the DtsCreator. This lets
10+
// you change the default options of the DtsCreator and e.g. use a different
11+
// output folder.
12+
var queryOptions = loaderUtils.parseQuery(this.query);
13+
var options;
14+
if (queryOptions) {
15+
options = objectAssign({}, queryOptions);
16+
}
17+
18+
var creator = new DtsCreator(options);
19+
920
// creator.create(..., source) tells the module to operate on the
1021
// source variable. Check API for more details.
1122
creator.create(this.resourcePath, source).then(content => {

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@
2222
"license": "MIT",
2323
"bugs": {
2424
"url": "https://github.com/olegstepura/typed-css-modules-loader/issues"
25+
},
26+
"dependencies": {
27+
"loader-utils": "^0.2.15",
28+
"object-assign": "^4.1.0"
2529
}
2630
}

0 commit comments

Comments
 (0)