|
| 1 | +# rollup-plugin-write-only-changes |
| 2 | + |
| 3 | +[ |
| 4 | +  |
| 5 | +](https://www.npmjs.com/package/rollup-plugin-write-only-changes) |
| 6 | + |
| 7 | +A [Rollup] Rollup plugin for writing files to the output directoriy only if their contents actually changed. |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +This plugin requires [Node.js] [LTS] (currently 18, at least 14.8) and Rollup 1.20 or newer. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +Using npm: |
| 16 | + |
| 17 | + npm i -D rollup-plugin-write-only-changes |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +Create a `rollup.config.js` [configuration file] and import the plugin: |
| 22 | + |
| 23 | +```js |
| 24 | +import { writeOnlyChanges } from 'rollup-plugin-write-only-changes'; |
| 25 | + |
| 26 | +export default { |
| 27 | + input: 'src/index.js', |
| 28 | + output: { |
| 29 | + dir: 'output', |
| 30 | + format: 'cjs' |
| 31 | + }, |
| 32 | + plugins: [writeOnlyChanges()] |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +Then call `rollup` either via the [command-line] or the [programmatically]. |
| 37 | + |
| 38 | +## Options |
| 39 | + |
| 40 | +The plugin can be customised by the following options, which can be passed as an object with the properties below. |
| 41 | + |
| 42 | +### `verbose` |
| 43 | + |
| 44 | +Type: `boolean` | `{ missing, failing, existed, created, changed, intact }`<br> |
| 45 | +Default: `{ failing: true }` |
| 46 | + |
| 47 | +Logging configuration. All cases can be enabled by `true` and disabled |
| 48 | +by `false`. ingle cases are selectable by specifying an object with |
| 49 | +the following boolean properties, which are `false` by default, |
| 50 | +except for `failing`, which `true` by default: |
| 51 | + |
| 52 | + * `missing`: Log files, which were missing in the output directory. |
| 53 | + * `failing`: Log files, which failed when they tried to be read from the output directory. |
| 54 | + * `existed`: Log files, which already existed in the output directory and were read. |
| 55 | + * `created`: Log files, which had to be created in the output directory, |
| 56 | + because they did not exist there. |
| 57 | + * `changed`: Log files, which had to be rewritten in the output directory, |
| 58 | + because their content was different. |
| 59 | + * `intact`: Log files, which did not have to be rewritten in the output directory, |
| 60 | + because their content remained the same. |
| 61 | + |
| 62 | +### `rebuild` |
| 63 | + |
| 64 | +Type: `boolean`<br> |
| 65 | +Default: `false` |
| 66 | + |
| 67 | +If the output files should be forcibly written at least once, when rollup |
| 68 | +starts and the project is built at first, before the watcher starts. |
| 69 | + |
| 70 | +## Contributing |
| 71 | + |
| 72 | +In lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code. |
| 73 | + |
| 74 | +## License |
| 75 | + |
| 76 | +Copyright (C) 2023 Ferdinand Prantl |
| 77 | + |
| 78 | +Licensed under the [MIT License]. |
| 79 | + |
| 80 | +[MIT License]: http://en.wikipedia.org/wiki/MIT_License |
| 81 | +[Rollup]: https://rollupjs.org/ |
| 82 | +[Node.js]: https://nodejs.org/ |
| 83 | +[LTS]: https://github.com/nodejs/Release |
| 84 | +[configuration file]: https://www.rollupjs.org/guide/en/#configuration-files |
| 85 | +[command-line]: https://www.rollupjs.org/guide/en/#command-line-reference |
| 86 | +[programmatically]: https://www.rollupjs.org/guide/en/#javascript-api |
0 commit comments