Skip to content

Commit d5fc994

Browse files
authored
Merge pull request #20 from Jimdo/fix-options-and-missing-context
fix: use correct options object & set fallback context
2 parents ce2cf1d + 3604275 commit d5fc994

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ module.exports = function(source, map) {
1010
// Pass on query parameters as an options object to the DtsCreator. This lets
1111
// you change the default options of the DtsCreator and e.g. use a different
1212
// output folder.
13-
var queryOptions = loaderUtils.getOptions(this);
14-
var options;
15-
var emitFile = true;
16-
if (queryOptions) {
17-
options = Object.assign({}, queryOptions);
18-
emitFile = !options.noEmit;
19-
delete options.noEmit;
20-
}
13+
var options = loaderUtils.getOptions(this) || {};
14+
var context = options.context || this.context || this.rootContext;
15+
var emitFile = !options.noEmit;
16+
delete options.noEmit;
2117

2218
var creator = new DtsCreator(options);
2319

@@ -26,7 +22,7 @@ module.exports = function(source, map) {
2622
creator.create(this.resourcePath, source).then(content => {
2723
if (emitFile) {
2824
// Emit the created content as well
29-
this.emitFile(path.relative(this.options.context, content.outputFilePath), content.contents || [''], map);
25+
this.emitFile(path.relative(context, content.outputFilePath), content.contents || [''], map);
3026
}
3127
content.writeFile().then(_ => {
3228
callback(null, source, map);

0 commit comments

Comments
 (0)