Skip to content

Commit 1ec3f5b

Browse files
authored
Merge pull request olegstepura#19 from vpoverennov/master
add noEmit option
2 parents 1168bcb + fbb27cf commit 1ec3f5b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ I suggest using it as preloader. Unless you change the options (see below), it
66
will generate `.css.d.ts` files near the `.css`. Please take a look at
77
[this discussion](https://github.com/Quramy/typed-css-modules/issues/2) to make a decision.
88

9+
It has one option - noEmit, which turns off emitting files to the output path of webpack.
10+
911
You can affect how `typed-css-modules` behaves by using query parameters. The loader
10-
will pass any query parameters you specify to the constructor of the `DtsCreator`
12+
will pass any query parameters you specify (excluding noEmit) to the constructor of the `DtsCreator`
1113
class. For more info on available options, please take a look here:
1214
[DtsCreator constructor](https://github.com/Quramy/typed-css-modules#new-dtscreatoroption).
1315

@@ -25,6 +27,8 @@ const settings = {
2527
loader: 'typed-css-modules'
2628
// or in case you want to use parameters:
2729
// loader: 'typed-css-modules?outDir=/tmp'
30+
// or in case you want to use noEmit:
31+
// loader: 'typed-css-modules?noEmit'
2832
}
2933
],
3034
}

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,22 @@ module.exports = function(source, map) {
1212
// output folder.
1313
var queryOptions = loaderUtils.getOptions(this);
1414
var options;
15+
var emitFile = true;
1516
if (queryOptions) {
1617
options = Object.assign({}, queryOptions);
18+
emitFile = !options.noEmit;
19+
delete options.noEmit;
1720
}
1821

1922
var creator = new DtsCreator(options);
2023

2124
// creator.create(..., source) tells the module to operate on the
2225
// source variable. Check API for more details.
2326
creator.create(this.resourcePath, source).then(content => {
24-
// Emit the created content as well
25-
this.emitFile(path.relative(this.options.context, content.outputFilePath), content.contents || [''], map);
27+
if (emitFile) {
28+
// Emit the created content as well
29+
this.emitFile(path.relative(this.options.context, content.outputFilePath), content.contents || [''], map);
30+
}
2631
content.writeFile().then(_ => {
2732
callback(null, source, map);
2833
});

0 commit comments

Comments
 (0)