Skip to content

Commit

Permalink
Init package
Browse files Browse the repository at this point in the history
  • Loading branch information
vladshcherbin committed Jul 3, 2018
0 parents commit e6d607b
Show file tree
Hide file tree
Showing 7 changed files with 1,291 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: 'airbnb-base',
rules: {
'comma-dangle': ['error', 'never'],
semi: ['error', 'never']
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "rollup-plugin-delete",
"description": "Delete files and folders using Rollup",
"version": "0.1.0",
"author": "Vlad Shcherbin <[email protected]>",
"repository": "vladshcherbin/rollup-plugin-delete",
"main": "dist/index.js",
"scripts": {
"lint": "eslint src",
"build": "rollup -c",
"clean": "rimraf dist",
"prepublishOnly": "yarn lint && yarn build",
"postpublish": "yarn clean"
},
"dependencies": {
"del": "^3.0.0"
},
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-plugin-import": "^2.13.0",
"rimraf": "^2.6.2",
"rollup": "^0.62.0"
},
"files": [
"dist",
"readme.md"
],
"keywords": [
"rollup",
"plugin",
"delete",
"clear",
"clean",
"remove"
],
"license": "MIT"
}
65 changes: 65 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# rollup-plugin-delete

Delete files and folders using Rollup.

## About

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.

## Installation

```bash
npm install rollup-plugin-delete --save-dev
# or
yarn add rollup-plugin-delete -D
```

## Usage

```js
// rollup.config.js
import del from 'rollup-plugin-delete'

export default {
input: 'src/index.js',
output: {
file: 'dist/app.js',
format: 'cjs'
},
plugins: [
del({ targets: 'dist/*' })
]
}
```

### Configuration

There are some useful options:

**targets**

A string or an array of patterns of files and folders to be deleted. Default is `[]`.

```js
del({
targets: 'dist/*'
})

del({
targets: ['dist/*', 'build/*']
})
```

**verbose**

If set to `true`, will output removed files and folders to console. Default is `false`.

```js
del({
verbose: true
})
```

## License

MIT
8 changes: 8 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
input: 'src/index.js',
output: {
file: 'dist/index.js',
format: 'cjs'
},
external: ['del']
}
20 changes: 20 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-disable no-console */
import del from 'del'

export default function (options = {}) {
const targets = options.targets || []
const verbose = options.verbose || false

return {
name: 'delete',
buildStart: () => del(targets).then((paths) => {
if (verbose && paths.length > 0) {
console.log('Deleted files and folders:')

paths.forEach((path) => {
console.log(path)
})
}
})
}
}
Loading

0 comments on commit e6d607b

Please sign in to comment.