|
1 | | -# rollup-plugin-insert |
| 1 | +# @rxts/rollup |
2 | 2 |
|
3 | 3 | [](https://github.com/rx-ts/rollup-plugin-insert/actions?query=workflow%3A%22Node+CI%22) |
4 | | -[](https://codecov.io/gh/rx-ts/rollup-plugin-insert) |
5 | | -[](https://www.codacy.com/gh/rx-ts/rollup-plugin-insert) |
| 4 | +[](https://codecov.io/gh/rx-ts/rollup) |
| 5 | +[](https://www.codacy.com/gh/rx-ts/rollup) |
6 | 6 | [](https://github.com/plantain-00/type-coverage) |
7 | | -[](https://www.npmjs.com/package/rollup-plugin-insert) |
8 | 7 | [](https://github.com/rx-ts/rollup-plugin-insert/releases) |
9 | | - |
10 | | -[](https://david-dm.org/rx-ts/rollup-plugin-insert?type=peer) |
11 | | -[](https://david-dm.org/rx-ts/rollup-plugin-insert) |
12 | 8 | [](https://david-dm.org/rx-ts/rollup-plugin-insert?type=dev) |
13 | 9 |
|
14 | 10 | [](https://conventionalcommits.org) |
|
17 | 13 | [](https://github.com/prettier/prettier) |
18 | 14 | [](https://codechecks.io) |
19 | 15 |
|
20 | | -> string mutation plugin for rollup |
21 | | -
|
22 | | -## Usage |
23 | | - |
24 | | -```bash |
25 | | -# npm |
26 | | -npm install -D rollup-plugin-insert |
27 | | - |
28 | | -# yarn |
29 | | -yarn add -D rollup-plugin-insert |
30 | | -``` |
31 | | - |
32 | | -```js |
33 | | -// all of following is fine |
34 | | -import * as insert from 'rollup-plugin-insert' |
35 | | -import insert from 'rollup-plugin-insert' |
36 | | -import { append, prepend, wrap, transform } from 'rollup-plugin-insert' |
37 | | - |
38 | | -const insert = require('rollup-plugin-insert') |
39 | | -``` |
40 | | - |
41 | | -## Common Usage |
42 | | - |
43 | | -All following methods have an optional last argument `options` which is an object and contains key `include`, `exclude` and `sourceMap` which is enabled by default. |
44 | | - |
45 | | -It can be used to filter files as you like. For example you can wrapper your html template as following: |
46 | | - |
47 | | -```js |
48 | | -insert.transform( |
49 | | - (magicString, code, id) => |
50 | | - `export default ${JSON.stringify(`<!--add some comments-->${code}`)}`, |
51 | | - { |
52 | | - include: '**/*.html', |
53 | | - }, |
54 | | -) |
55 | | -``` |
56 | | - |
57 | | -If you do not need `sourceMap` at all, just change it to be `false`. |
58 | | - |
59 | | -## Append |
60 | | - |
61 | | -Appends a string onto the contents. |
62 | | - |
63 | | -```js |
64 | | -insert.append('world') // Appends 'world' to the contents of every file |
65 | | -``` |
66 | | - |
67 | | -## Prepend |
| 16 | +> Incredible Rollup plugins, make Rollup greater |
68 | 17 |
|
69 | | -Prepends a string onto the contents. |
| 18 | +## Packages |
70 | 19 |
|
71 | | -```js |
72 | | -insert.prepend('Hello') // Prepends 'Hello' to the contents of every file |
73 | | -``` |
| 20 | +This repository is a monorepo managed by [Lerna][] what means we actually publish several packages to npm from same codebase, including: |
74 | 21 |
|
75 | | -## Wrap |
| 22 | +| Package | Description | Version | Peer Dependencies | Dependencies | |
| 23 | +| ------------------------------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | |
| 24 | +| [`rollup-plugin-insert`](/packages/insert) | string mutation plugin for Rollup | [](https://www.npmjs.com/package/rollup-plugin-insert) | [](https://david-dm.org/rx-ts/rollup?path=packages/insert&type=peer) | [](https://david-dm.org/rx-ts/rollup?path=packages/insert) | |
76 | 25 |
|
77 | | -Wraps the contents with two strings. |
| 26 | +## Changelog |
78 | 27 |
|
79 | | -```js |
80 | | -insert.wrap('Hello', 'World') // prepends 'hello' and appends 'world' to the contents |
81 | | -``` |
| 28 | +Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md). |
82 | 29 |
|
83 | | -## Transform |
| 30 | +## License |
84 | 31 |
|
85 | | -Calls a function with the contents of the file. |
| 32 | +[MIT][] © [JounQin][]@[1stG.me][] |
86 | 33 |
|
87 | | -```js |
88 | | -insert.transform((magicString, code, id) => code.toUpperCase()) // should return a string or MagicString |
89 | | -``` |
| 34 | +[1stg.me]: https://www.1stg.me |
| 35 | +[jounqin]: https://GitHub.com/JounQin |
| 36 | +[lerna]: https://github.com/lerna/lerna |
| 37 | +[mit]: http://opensource.org/licenses/MIT |
0 commit comments