This is a small webpack plugin to export only declaration files you choose. It's connected with ts-loader. So you install it first and then add "declaration": true in tsconfig.json.
yarn add -D ts-loader-declaration-export-plugin
npm install -D ts-loader-declaration-export-plugin
// webpack.config.js
const DeclarationExportPlugin = require('ts-loader-declaration-export-plugin');
module.exports = {
...
plugins: [
new DeclarationExportPlugin({
modulePath: 'src/index.d.ts',
output: 'index.d.ts',
}),
],
...
}