-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
logs | ||
*.log | ||
npm-debug.log* | ||
package-lock.json | ||
yarn.lock | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,92 @@ | ||
rollup-plugin-output | ||
==== | ||
|
||
![](https://img.shields.io/npm/v/rollup-plugin-output.svg?style=flat) | ||
|
||
Custom output format for rollup. | ||
|
||
## Installation | ||
|
||
```shell | ||
$ npm install --save-dev rollup-plugin-output | ||
``` | ||
|
||
Or | ||
|
||
```shell | ||
$ yarn add -D rollup-plugin-output | ||
``` | ||
|
||
## Example | ||
|
||
### Generate JSON format file | ||
|
||
```ts | ||
// src/manifest.ts | ||
import * as pkg from "../package.json"; | ||
|
||
export default { | ||
name: pkg.name, | ||
description: pkg.description, | ||
version: pkg.version, | ||
app: { | ||
background: { | ||
scripts: ["background.js"] | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
```js | ||
// rollup.config.js | ||
import json from "rollup-plugin-json"; | ||
import output from "rollup-plugin-output"; | ||
|
||
const manifest = { | ||
input: "src/manifest.ts", | ||
output: { | ||
file: "dist/manifest.json", | ||
format: "json" | ||
}, | ||
plugins: [json(), output()] | ||
}; | ||
|
||
export default [manifest]; | ||
``` | ||
|
||
```json | ||
// dist/manifest.json | ||
{ | ||
"name": "shadowsocks-chromeos", | ||
"description": "", | ||
"version": "1.0.0", | ||
"app": { | ||
"background": { | ||
"scripts": [ | ||
"background.js" | ||
] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Advanced Config(Custom output function) | ||
|
||
```js | ||
// rollup.config.js | ||
const manifest = { | ||
input: "src/manifest.ts", | ||
output: { | ||
file: "dist/manifest.txt", | ||
format (code) { | ||
return "Hello World"; | ||
} | ||
}, | ||
plugins: [json(), output()] | ||
}; | ||
``` | ||
|
||
```js | ||
// dist/manifest.txt | ||
Hello World | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "rollup-plugin-output", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "dist/rollup-plugin-output.cjs.js", | ||
"module": "dist/rollup-plugin-output.es.js", | ||
"author": "Gitai <[email protected]>", | ||
|
@@ -18,7 +18,7 @@ | |
], | ||
"scripts": { | ||
"build": "rollup -c", | ||
"prebuild": "rm -rf dist/*", | ||
"prebuild": "shx rm -rf dist/*", | ||
"prepare": "npm run build" | ||
}, | ||
"dependencies": { | ||
|
@@ -34,10 +34,10 @@ | |
"typescript": "^3.4.3" | ||
}, | ||
"files": [ | ||
"src", | ||
"dist", | ||
"index.d.ts", | ||
"README.md" | ||
"LICENSE", | ||
"README.md", | ||
"package.json" | ||
], | ||
"repository": "gitaiQAQ/rollup-plugin-output" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters