Skip to content

ns0m/witty-webpack-declaration-files

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A webpack plugin for manipulating d.ts files

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 91.4%
  • TypeScript 4.4%
  • HTML 4.2%