Publication version of the ahrakio/witty-webpack-declaration-files package with some fixes.
A webpack plugin for manipulating d.ts files
npm i -D @ns0m/witty-webpack-declaration-files
{
...
compilerOptions: {
...
declaration: true
}
}
const DeclarationFilesPlugin = require("@ns0m/witty-webpack-declaration-files");
...
module.exports = {
...
plugins: [
...
new DeclarationFilesPlugin({
// options goes here
merge: true,
exclude: ["server", "*Routes"],
flatten: true
})
]
}
The options are:
merge
: boolean - default: false
To merge the declaration files into one file.include
: string[] - default: []
Names of the files to be included in the final bundle (without filename extensions ; for MyClass.ts mention "MyClass").exclude
: string[] - default: []
Names of the files to be excluded from the final bundle. Add "*PartialFileName" or "PartialFileName*" to support dynamic filenames to exclude.flatten
: boolean - default: false
To put all the declaration files in the root path of the dist folder.
Leaving merge
as false, the plugin will generate only the files in the include
array, or all the files which are not in the exclude
array, according to the configuration - but will not merge them into one file.
See basic example in /example
.
(Be careful as this example declares @ns0m/witty-webpack-declaration-files dependency through a reference to its own parent file directory, and some IDE end in an infinite loop trying to index dependencies.)
- version 2.x published from here is made for Webpack = 4
- version 1.x from ahrakio should be used for Webpack < 4