{"id":13774246,"url":"https://github.com/NotWoods/rollup-plugin-consts","last_synced_at":"2025-05-11T06:32:37.467Z","repository":{"id":35063282,"uuid":"202350516","full_name":"NotWoods/rollup-plugin-consts","owner":"NotWoods","description":"Import build time constants with Rollup","archived":false,"fork":false,"pushed_at":"2024-01-27T06:02:57.000Z","size":385,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-27T21:43:15.831Z","etag":null,"topics":["constants","proxx","rollup","rollup-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NotWoods.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-08-14T12:54:25.000Z","updated_at":"2024-06-18T19:59:21.451Z","dependencies_parsed_at":"2024-01-13T11:57:51.208Z","dependency_job_id":"c8c27251-3e9f-4877-a388-25a6e8bb2ee0","html_url":"https://github.com/NotWoods/rollup-plugin-consts","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"5936cd033dfc6b23db615d6b09ab92a164581710"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Frollup-plugin-consts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Frollup-plugin-consts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Frollup-plugin-consts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NotWoods%2Frollup-plugin-consts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NotWoods","download_url":"https://codeload.github.com/NotWoods/rollup-plugin-consts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225022046,"owners_count":17408543,"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":["constants","proxx","rollup","rollup-plugin"],"created_at":"2024-08-03T17:01:25.013Z","updated_at":"2024-11-17T09:30:40.115Z","avatar_url":"https://github.com/NotWoods.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Modules"],"readme":"# rollup-plugin-consts\n\n[![](https://img.shields.io/npm/v/rollup-plugin-consts.svg?style=flat)](https://www.npmjs.com/package/rollup-plugin-consts)\n\nImport build time constants with Rollup.\n\n## Installation\n\n```bash\nnpm install --save-dev rollup-plugin-consts\n```\n\n## Usage\n\nrollup-plugin-consts let you use constants that are replaced at build time, such\nas inlining your `NODE_ENV`. Unlike similar plugins such as\n[rollup-plugin-replace](https://github.com/rollup/rollup-plugin-replace),\nrollup-plugin-consts doesn't magically replace strings in your script. Instead,\nyou import them like a module.\n\n```js\n// script.js\nimport environment from 'consts:environment';\n\nif (environment === 'production') {\n    // Production only code ...\n} else {\n    // Development only code ...\n}\n```\n\nAll consts modules have the prefix `consts:` followed by the name of the\nconstant, such as `environment` or `testing`. Rollup can reduce simple `if`\nstatements like the one above.\n\n```js\n// script.min.js\n\n// environment == 'production'\n{\n    // Production only code ...\n}\n```\n\nGenerally, you need to ensure that rollup-plugin-consts goes _before_ other\nthings (like rollup-plugin-commonjs) in your `plugins` array, so that those\nplugins can apply any optimisations such as dead code removal.\n\n```js\n// rollup.config.js\nimport consts from 'rollup-plugin-consts';\n\nexport default {\n    // ...\n    plugins: [\n        consts({\n            environment: 'production',\n        }),\n    ],\n};\n```\n\n## Options\n\n```js\n{\n    // All options are treated as `string: replacement` replacers...\n    testing: false,\n    version: '1.0.0',\n    environment: 'development',\n    // Objects can be used as replacements too!\n    config: { names: ['foo', 'bar'] },\n}\n```\n\n## TypeScript\n\nThe `consts` function is has a typings file. See\n[Usage with TypeScript](https://github.com/NotWoods/rollup-plugin-consts/wiki/Usage-with-TypeScript)\nto check how to create additional typings files for importing constants.\n\n## Credits\n\nrollup-plugin-consts was originally created by\n[Jake Archibald](https://github.com/jakearchibald/) for\n[PROXX](https://github.com/GoogleChromeLabs/proxx). You can watch his\npresentation with [Surma](https://github.com/surma/)\n[about Rollup plugins they wrote for PROXX](https://youtu.be/TsTt7Tja30Q).\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNotWoods%2Frollup-plugin-consts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNotWoods%2Frollup-plugin-consts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNotWoods%2Frollup-plugin-consts/lists"}