esbuild-plugin-clean
Version:
ESBuild plugin for cleaning up assets before building.
44 lines • 3.56 kB
JSON
{
"name": "esbuild-plugin-clean",
"version": "1.0.1",
"description": "ESBuild plugin for cleaning up assets before building.",
"keywords": [
"esbuild",
"ESBuild",
"clean",
"plugin"
],
"homepage": "https://github.com/LinbuduLab/esbuild-plugins/tree/master/packages/esbuild-plugin-clean#readme",
"changelog": "https://github.com/LinbuduLab/esbuild-plugins/blob/main/packages/esbuild-plugin-clean/CHANGELOG.md",
"bugs": {
"url": "https://github.com/LinbuduLab/esbuild-plugins/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/LinbuduLab/esbuild-plugins.git"
},
"license": "MIT",
"author": "Linbudu <linbudu599@gmail.com> (https://github.com/linbudu599)",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"publishConfig": {},
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"dependencies": {
"chalk": "^4.1.2",
"del": "^6.0.0"
},
"peerDependencies": {
"esbuild": ">= 0.14.0"
},
"scripts": {
"dev": "tsup src/index.ts --watch --dts --format esm",
"build": "rm -rf dist && tsup src/index.ts --config ../../tsup.config.ts"
},
"readme": "# esbuild-plugin-clean\n\nESBuild plugin for cleaning up output/assets before building.\n\n- [Author](https://github.com/linbudu599)\n- [GitHub Repo](https://github.com/LinbuduLab/esbuild-plugins/tree/master/packages/esbuild-plugin-clean#readme)\n- [Changelog](https://github.com/LinbuduLab/esbuild-plugins/blob/main/packages/esbuild-plugin-clean/CHANGELOG.md)\n\n## Usage\n\n```bash\nnpm install esbuild-plugin-clean --save-dev\npnpm install esbuild-plugin-clean --save-dev\nyarn add esbuild-plugin-clean --save-dev\n```\n\n```typescript\nimport { build } from 'esbuild';\nimport { clean } from 'esbuild-plugin-clean';\n\n(async () => {\n const res = await build({\n entryPoints: ['./demo.ts'],\n bundle: true,\n outfile: './dist/main.js',\n plugins: [\n clean({\n patterns: ['./dist/*', './dist/assets/*.map.js'],\n cleanOnStartPatterns: ['./prepare'],\n cleanOnEndPatterns: ['./post'],\n }),\n ],\n });\n})();\n```\n\n## Configurations\n\nThis plugin use [del](https://www.npmjs.com/package/del) under the hood, so you can easily pass `del options` to this plugin.\n\n```typescript\nexport interface CleanOptions {\n /**\n * file clean patterns (passed to `del`)\n *\n * @default: []\n */\n patterns?: string | string[];\n\n /**\n * file clean patterns(in onStart only) (passed to `del`)\n *\n * @default: []\n */\n cleanOnStartPatterns?: string | string[];\n\n /**\n * file clean patterns(in onEnd only) (passed to `del`)\n *\n * @default: []\n */\n cleanOnEndPatterns?: string | string[];\n\n /**\n * use dry-run mode to see what's going to happen\n *\n * this option will enable verbose option automatically\n *\n * @default: false\n */\n dryRun?: boolean;\n\n /**\n * extra options passed to `del`\n *\n * @default {}\n */\n options?: DelOptions;\n\n /**\n * execute clean sync or async (use `del` or `del.sync` for cleaning up)\n *\n * @default: true\n */\n sync?: boolean;\n\n /**\n * do cleaning in start / end / both\n * maybe in some strange cases you will need it ? :P\n *\n * @default: \"start\"\n */\n cleanOn?: 'start' | 'end' | 'both';\n\n /**\n * enable verbose logging to see what's happening\n *\n * @default false\n */\n verbose?: boolean;\n}\n```\n"
}