|
1 | 1 | # rollup-plugin-atomic |
2 | | - Rollup preset used in atom-ide-community |
| 2 | + |
| 3 | +Rollup plugin used in atom-ide-community |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +``` |
| 8 | +npm install --save-dev rollup-plugin-atomic |
| 9 | +``` |
| 10 | + |
| 11 | +You should also install the peer dependencies: |
| 12 | + |
| 13 | +``` |
| 14 | +"rollup": "2.21.0", |
| 15 | +``` |
| 16 | + |
| 17 | +``` |
| 18 | +"typescript": "^3.9.6", |
| 19 | +"coffeescript": "^1.12.7", |
| 20 | +"@babel/core": "^7.10.5", |
| 21 | +``` |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +Create a `rollup.config.js` file at the root of the project with the following content. See API section for more details |
| 26 | + |
| 27 | +```js |
| 28 | +const { createPlugins, createConfig } = requore("rollup-plugin-atomic"); |
| 29 | + |
| 30 | +const plugins = createPlugins(["js"], true); |
| 31 | + |
| 32 | +const config = createConfig( |
| 33 | + "src/x-terminal.js", |
| 34 | + "dist", |
| 35 | + "cjs", |
| 36 | + ["atom", "electron", "node-pty-prebuilt-multiarch"], |
| 37 | + plugins |
| 38 | +); |
| 39 | + |
| 40 | +module.exports = config; |
| 41 | +``` |
| 42 | + |
| 43 | +## API |
| 44 | + |
| 45 | +use `createPlugins` to create the plugins you need. |
| 46 | + |
| 47 | +```ts |
| 48 | +createPlugins( |
| 49 | + languages: Array<string> = ["ts", "js", "json", "coffee"], // languages you use |
| 50 | + babel: boolean = true, // if you want to use babel |
| 51 | + extraPlugins?: Array<any> // pass any extra plugins functions like `multientry()` |
| 52 | +) |
| 53 | +``` |
| 54 | + |
| 55 | +use `createConfig` to create the configs you need |
| 56 | + |
| 57 | +```ts |
| 58 | +createConfig( |
| 59 | + input: string | Array<string> = "src/main.ts", // bundle's input(s) file(s) |
| 60 | + output_dir: string = "dist", // where the bundle is stored |
| 61 | + output_format = "cjs", // output format (e.g. `cjs`, `es`, etc) |
| 62 | + externals: Array<string> = ["atom", "electron"], // libraries you want to be external |
| 63 | + plugins = createPlugins() // pass the plugins you created using `createPlugins()` |
| 64 | +) |
| 65 | +``` |
| 66 | +You can create multiple configs using `createConfig` and export them as an array: |
| 67 | +```js |
| 68 | +module.exports = [config1, config2] |
| 69 | +``` |
0 commit comments