@jakehamilton/dts-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.4.5 • Public • Published

@jakehamilton/dts-webpack-plugin

Generate type definitions after your webpack build.

Installation

npm install --save-dev @jakehamilton/dts-webpack-plugin

Usage

const DTSWebpackPlugin = require("@jakehamilton/dts-webpack-plugin");

module.exports = {
    plugins: [
        new DTSWebpackPlugin({
            // Optional root directory to search for package.json,
            // tsconfig.json, and code in.
            root: "/my/project/",

            // Optional arguments for the typescript compiler.
            tsc: "--strict",

            // Optional path to a tsconfig.json file.
            tsconfig: "/my/project/tsconfig.json",

            // Optional function to determine whether a module should be
            // included or not.
            match: (name) => !name.endsWith(".stories.ts"),

            // Optional map of transformations.
            transforms: {
                module: (origin, identifier, line, files, aliases) => {
                    // `origin` is the module that an import/export takes place.
                    // `identifier` is the name/path of the import/export.
                    // `line` is the whole line where the import/export occurs.
                    // `files` is an object containing all type definition files and their contents.
                    // `aliases` is an object of aliases from your tsconfig.json file.

                    // Example removing css imports
                    // WARNING: this only works if the import was written on one line.
                    if (identifier.endsWith(".css")) {
                        return "";
                    }
                },
            },
        }),
    ],
};

Readme

Keywords

Package Sidebar

Install

npm i @jakehamilton/dts-webpack-plugin

Weekly Downloads

19

Version

1.4.5

License

Apache-2.0

Unpacked Size

27.9 kB

Total Files

9

Last publish

Collaborators

  • jakehamilton