Skip to content

Commit e6d607b

Browse files
committed
Init package
0 parents  commit e6d607b

File tree

7 files changed

+1291
-0
lines changed

7 files changed

+1291
-0
lines changed

.eslintrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
extends: 'airbnb-base',
3+
rules: {
4+
'comma-dangle': ['error', 'never'],
5+
semi: ['error', 'never']
6+
}
7+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

package.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "rollup-plugin-delete",
3+
"description": "Delete files and folders using Rollup",
4+
"version": "0.1.0",
5+
"author": "Vlad Shcherbin <[email protected]>",
6+
"repository": "vladshcherbin/rollup-plugin-delete",
7+
"main": "dist/index.js",
8+
"scripts": {
9+
"lint": "eslint src",
10+
"build": "rollup -c",
11+
"clean": "rimraf dist",
12+
"prepublishOnly": "yarn lint && yarn build",
13+
"postpublish": "yarn clean"
14+
},
15+
"dependencies": {
16+
"del": "^3.0.0"
17+
},
18+
"devDependencies": {
19+
"eslint": "^4.19.1",
20+
"eslint-config-airbnb-base": "^13.0.0",
21+
"eslint-plugin-import": "^2.13.0",
22+
"rimraf": "^2.6.2",
23+
"rollup": "^0.62.0"
24+
},
25+
"files": [
26+
"dist",
27+
"readme.md"
28+
],
29+
"keywords": [
30+
"rollup",
31+
"plugin",
32+
"delete",
33+
"clear",
34+
"clean",
35+
"remove"
36+
],
37+
"license": "MIT"
38+
}

readme.md

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# rollup-plugin-delete
2+
3+
Delete files and folders using Rollup.
4+
5+
## About
6+
7+
This plugin is useful when you want to clean `dist` or other folders and files before bundling. It's using [del](https://github.com/sindresorhus/del) package inside, check it for pattern examples.
8+
9+
## Installation
10+
11+
```bash
12+
npm install rollup-plugin-delete --save-dev
13+
# or
14+
yarn add rollup-plugin-delete -D
15+
```
16+
17+
## Usage
18+
19+
```js
20+
// rollup.config.js
21+
import del from 'rollup-plugin-delete'
22+
23+
export default {
24+
input: 'src/index.js',
25+
output: {
26+
file: 'dist/app.js',
27+
format: 'cjs'
28+
},
29+
plugins: [
30+
del({ targets: 'dist/*' })
31+
]
32+
}
33+
```
34+
35+
### Configuration
36+
37+
There are some useful options:
38+
39+
**targets**
40+
41+
A string or an array of patterns of files and folders to be deleted. Default is `[]`.
42+
43+
```js
44+
del({
45+
targets: 'dist/*'
46+
})
47+
48+
del({
49+
targets: ['dist/*', 'build/*']
50+
})
51+
```
52+
53+
**verbose**
54+
55+
If set to `true`, will output removed files and folders to console. Default is `false`.
56+
57+
```js
58+
del({
59+
verbose: true
60+
})
61+
```
62+
63+
## License
64+
65+
MIT

rollup.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
input: 'src/index.js',
3+
output: {
4+
file: 'dist/index.js',
5+
format: 'cjs'
6+
},
7+
external: ['del']
8+
}

src/index.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* eslint-disable no-console */
2+
import del from 'del'
3+
4+
export default function (options = {}) {
5+
const targets = options.targets || []
6+
const verbose = options.verbose || false
7+
8+
return {
9+
name: 'delete',
10+
buildStart: () => del(targets).then((paths) => {
11+
if (verbose && paths.length > 0) {
12+
console.log('Deleted files and folders:')
13+
14+
paths.forEach((path) => {
15+
console.log(path)
16+
})
17+
}
18+
})
19+
}
20+
}

0 commit comments

Comments
 (0)