❗⚠️❗ Warning:
These modifications will override the default behavior and configuration of DTS. As such they can invalidate internal guarantees and assumptions. These types of changes can break internal behavior and can be very fragile against updates. Use with discretion!
DTS uses Rollup under the hood. The defaults are solid for most packages (Formik uses the defaults!). However, if you do wish to alter the rollup configuration, you can do so by creating a file called dts.config.js
(or dts.config.ts
) at the root of your project like so:
dts.config.js
1// Not transpiled with TypeScript or Babel, so use plain Es6/Node.js!2/**3* @type {import('dts-cli').DtsConfig}4*/5module.exports = {6// This function will run for each entry/format/env combination7rollup(config, options) {8return config; // always return a config.9},10};
or
1const defineConfig = require('dts-cli').defineConfig;23module.exports = defineConfig({4// This function will run for each entry/format/env combination5rollup: (config, options) => {6return config; // always return a config.7},8});
dts.config.ts
1import { defineConfig } from 'dts-cli';23export default defineConfig({4rollup: (config, options) => {5return config; // always return a config.6},7});
The options
object contains the following:
1export interface DtsOptions {2// path to file3input: string;4// Name of package5name: string;6// JS target7target: 'node' | 'browser';8// Module format9format: 'cjs' | 'umd' | 'esm' | 'system';10// Environment11env: 'development' | 'production';12// Path to tsconfig file13tsconfig?: string;14// Is error extraction running?15extractErrors?: boolean;16// Is minifying?17minify?: boolean;18// Is this the very first rollup config (and thus should one-off metadata be extracted)?19writeMeta?: boolean;20// Only transpile, do not type check (makes compilation faster)21transpileOnly?: boolean;22}
1const postcss = require('rollup-plugin-postcss');2const autoprefixer = require('autoprefixer');3const cssnano = require('cssnano');45module.exports = {6rollup(config, options) {7config.plugins.push(8postcss({9plugins: [10autoprefixer(),11cssnano({12preset: 'default',13}),14],15inject: false,16// only write out CSS for the first bundle (avoids pointless extra files):17extract: !!options.writeMeta,18})19);20return config;21},22};
You can add your own .babelrc
to the root of your project and DTS will merge it with its own Babel transforms (which are mostly for optimization), putting any new presets and plugins at the end of its list.
You can add your own jest.config.js
to the root of your project and DTS will shallow merge it with its own Jest config.
You can add your own .eslintrc.js
to the root of your project and DTS will deep merge it with its own ESLint config.