Skip to content
This repository was archived by the owner on Oct 30, 2020. It is now read-only.

Commit db3a7fe

Browse files
authored
Merge pull request #41 from jpap/banner-option
Banner support for generated type definitions
2 parents 4c8a251 + cd23afd commit db3a7fe

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ e.g.:
6565
{ test: /\.css$/, loader: 'typings-for-css-modules?silent' }
6666
```
6767

68+
### `banner`-option
69+
To add a "banner" prefix to each generated `*.d.ts` file, you can pass a string to this option as shown below. The prefix is quite literally prefixed into the generated file, so please ensure it conforms to the type definition syntax.
70+
71+
```js
72+
{ test: /\.css$/, loader: 'typings-for-css-modules?banner="// This file is automatically generated by typings-for-css-modules.\n// Please do not change this file!"' }
73+
```
74+
6875
## Usage
6976

7077
Keep your `webpack.config` as is just instead of using `css-loader` use `typings-for-css-modules-loader`

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ ${skippedDefinitions.map(sd => ` - "${sd}"`).join('\n').red}
6363
}
6464
cssModuleDefinition = generateNamedExports(cleanedDefinitions);
6565
}
66+
if (query.banner) {
67+
// Prefix banner to CSS module
68+
cssModuleDefinition = query.banner + '\n' + cssModuleDefinition;
69+
}
6670
persist.writeToFileIfChanged(cssModuleInterfaceFilename, cssModuleDefinition);
6771
// mock async step 3 - make `async` return the actual callback again before calling the 'real' css-loader
6872
delegateToCssLoader(this, input, callback);

0 commit comments

Comments
 (0)