Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Configure your webpack configuration file (webpack.config.js) to output a minimized bundle file (.js)
  2. Install the dts-webpack-plugin via npm or yarn
  3. Modify the plugins section of your webpack configuration file to include the following:
plugins: [
  new DtsBundlePlugin({
    name: '<library-name>',
    main: '<path-to-bundle.js>',
    out: '<path-to-output.d.ts>',
    removeSource: true,
    outputAsModuleFolder: true, // optional
    headerText: '', // optional
    footerText: '', // optional
  }),
  // ...
]
  1. Replace <library-name> with the actual name of your library
  2. Replace <path-to-bundle.js> with the actual path to the minimized bundle file
  3. Replace <path-to-output.d.ts> with the actual path where you want the .d.ts file to be generated
  4. Run webpack to generate the minimized bundle and the .d.ts file