`@cozka/rollup-create-dist-packagejson` is a Rollup plugin that edits the `package.json` during the build process and outputs it in the appropriate format in the output directory. It was created with the goal of outputting only the minimum required fie
npm install @cozka/rollup-create-dist-packagejson@cozka/rollup-create-dist-packagejson is a Rollup plugin that edits the package.json during the build process and outputs it in the appropriate format in the output directory.
package.json for publishing to npm,
sh
npm install @cozka/rollup-create-dist-packagejson --save-dev
`
Usage
Configure it in rollup.config.js as follows:
`js
import createDistPackageJson from '@cozka/rollup-create-dist-packagejson';
export default {
input: 'src/index.ts',
output: {
dir: 'dist',
format: 'esm',
},
plugins: [
createDistPackageJson({
content: {
main: './index.js',
types: './index.d.ts',
},
}),
],
};
`
Options
$3
- Partial or (packageJson: PackageJson) => Partial
- Specifies the content of the generated package.json.
$3
- string[]
- Specifies properties to inherit from the original package.json.
- Default: ['name', 'version', 'description', 'repository', 'bugs', 'homepage', 'author', 'contributors', 'license', 'type', 'engines', 'keywords']
$3
- string | undefined
- Specifies the directory where the original package.json is located.
- Default: Current directory
$3
- string | undefined
- Specifies the path to the directory containing workspace packages.
- Default: '..'
$3
- string | undefined
- Specifies the output directory for package.json.
- Default: Retrieved from Rollup's output settings
$3
- (packageJson: PackageJson) => PackageJson
- Processes the final package.json` before output.