{"id":24489118,"url":"https://github.com/kudashevs/vite-plugin-strip-code","last_synced_at":"2025-07-15T21:45:26.746Z","repository":{"id":265508524,"uuid":"896143995","full_name":"kudashevs/vite-plugin-strip-code","owner":"kudashevs","description":"A vite plugin that strips marked blocks from any code processed by vite.","archived":false,"fork":false,"pushed_at":"2024-12-02T15:49:04.000Z","size":74,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T12:38:20.880Z","etag":null,"topics":["strip-code","strip-unwanted","vite-plugin"],"latest_commit_sha":null,"homepage":"https://kudashevs.com/posts/2024/12/strip-code-library-and-plugins","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kudashevs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T16:28:41.000Z","updated_at":"2025-03-15T04:47:58.000Z","dependencies_parsed_at":"2025-01-21T16:33:26.107Z","dependency_job_id":"78c67051-d35f-4087-81a1-178c4b2e40d6","html_url":"https://github.com/kudashevs/vite-plugin-strip-code","commit_stats":null,"previous_names":["kudashevs/vite-plugin-strip-code"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kudashevs%2Fvite-plugin-strip-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kudashevs%2Fvite-plugin-strip-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kudashevs%2Fvite-plugin-strip-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kudashevs%2Fvite-plugin-strip-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kudashevs","download_url":"https://codeload.github.com/kudashevs/vite-plugin-strip-code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788915,"owners_count":21161727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["strip-code","strip-unwanted","vite-plugin"],"created_at":"2025-01-21T16:30:49.047Z","updated_at":"2025-04-13T22:11:44.965Z","avatar_url":"https://github.com/kudashevs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Vite Plugin Strip Code ![test workflow](https://github.com/kudashevs/vite-plugin-strip-code/actions/workflows/run-tests.yml/badge.svg)\n==========================\n\nThe `vite-plugin-strip-code` strips marked blocks from any type of code.\n\n## Install\n\n```bash\n# NPM\nnpm install --save-dev vite-plugin-strip-code\n# Yarn\nyarn add --dev vite-plugin-strip-code\n```\n\n\n## Options\n\n`ignoreNodeModules` is a boolean that defines whether to process the `node_modules` folder.\n\n`blocks` is an array of blocks' representations. Each element of this array describes a unique pair of tags with start, end,\nprefix, suffix and optional replacement. These values are represented by a string or an object with the following properties:\n```\nstart: 'dev-start'             # a string defines a name for the start tag (unique)\nend: 'dev-end'                 # a string defines a name for the end tag (unique)\nprefix: '/*'                   # a string defines the beginning of a tag\nsuffix: '*/'                   # a string defines the end of a tag\nreplacement: 'optional'        # a string defines a substitution for a removed block\n```\n\nThe plugin supports zero config. When no options are provided, it uses default start, end, prefix and suffix values.\n\n\n## Usage example\n\nFor example, suppose the task is to strip some debug information and non-production code from this code sample.\n```javascript\nfunction makeFoo(bar, baz) {\n    console.log('creating Foo'); \n    \n    if (bar instanceof Bar !== true) {\n        throw new Error('makeFoo: bar param must be an instance of Bar');\n    }\n    \n    if (baz instanceof Baz !== true) {\n        throw new Error('makeFoo: baz param must be an instance of Baz');\n    }\n    \n    return new Foo(bar, baz);\n}\n```\n\nThe plugin strips blocks of code marked with two paired tags (a block). A block is represented by a string or an object\nwith the properties described in \"[Options](#options)\" above. Let's identify two different blocks and describe them in the configuration:\n```javascript\n// vite.config.js \nimport {defineConfig} from 'vite';\nimport StripCode from 'vite-plugin-strip-code';\n\nexport default defineConfig({\n  plugins: [\n    StripCode({\n      blocks: [\n        'debug',\n        {\n          name: 'development',\n          prefix: '//',\n          suffix: '',\n        },\n      ],\n    }),\n  ],\n})\n```\n\nOnce the blocks are described in the configuration, the unwanted areas of code can be marked in the code:\n```javascript\nfunction makeFoo(bar, baz) {\n    /* debug-start */ console.log('creating Foo'); /* debug-end */\n    // dev-start\n    if (bar instanceof Bar !== true) {\n        throw new Error('makeFoo: bar param must be an instance of Bar');\n    }\n    // dev-end\n    // dev-start\n    if (baz instanceof Baz !== true) {\n        throw new Error('makeFoo: baz param must be an instance of Baz');\n    }\n    // dev-end\n    // This code will remain\n    return new Foo(bar, baz);\n}\n```\n\nAfter the building process, the marked blocks will be completely removed.\n```javascript\nfunction makeFoo(bar, baz) {\n    // This code will remain\n    return new Foo(bar, baz);\n}\n```\n\n\n## License\n\nThe MIT License (MIT). Please see the [License file](LICENSE.md) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkudashevs%2Fvite-plugin-strip-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkudashevs%2Fvite-plugin-strip-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkudashevs%2Fvite-plugin-strip-code/lists"}