@ns0m/witty-webpack-declaration-files

2.0.0 • Public • Published

Publication version of the ahrakio/witty-webpack-declaration-files package with some fixes. Latest Published Version


witty-webpack-declaration-files

A webpack plugin for manipulating d.ts files

Install via npm

npm i -D @ns0m/witty-webpack-declaration-files

Typescript - tsconfig.json

{
    ...
    compilerOptions: {
        ...
        declaration: true
    }
}

Webpack.config.js

const DeclarationFilesPlugin = require("@ns0m/witty-webpack-declaration-files");
...
module.exports = {
    ...
    plugins: [
        ...
        new DeclarationFilesPlugin({
            // options goes here
            merge: true,
            exclude: ["server", "*Routes"],
            flatten: true
        })
    ]
}

Note

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.

Example

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.)

Versions

  • version 2.x published from here is made for Webpack = 4
  • version 1.x from ahrakio should be used for Webpack < 4

Readme

Keywords

none

Package Sidebar

Install

npm i @ns0m/witty-webpack-declaration-files

Weekly Downloads

35

Version

2.0.0

License

ISC

Unpacked Size

17.7 kB

Total Files

4

Last publish

Collaborators

  • ath0mas