{"id":20673200,"url":"https://github.com/lutangar/extract-npm-package-config","last_synced_at":"2026-05-02T11:39:49.960Z","repository":{"id":143878684,"uuid":"113191911","full_name":"lutangar/extract-npm-package-config","owner":"lutangar","description":"Extract npm package config variables from `process.env` for in-app usage","archived":false,"fork":false,"pushed_at":"2017-12-06T15:04:46.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-18T19:11:19.224Z","etag":null,"topics":["config","env","npm","webpack"],"latest_commit_sha":null,"homepage":null,"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/lutangar.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}},"created_at":"2017-12-05T14:24:10.000Z","updated_at":"2017-12-06T15:05:17.000Z","dependencies_parsed_at":"2024-01-13T07:23:12.575Z","dependency_job_id":"a7a145ec-ddab-4554-9e7b-336b68023de3","html_url":"https://github.com/lutangar/extract-npm-package-config","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"6a7a3dcdf019ed1fa6d4c2fee29908d19443c05b"},"previous_names":["lutangar/export-npm-package-config"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lutangar%2Fextract-npm-package-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lutangar%2Fextract-npm-package-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lutangar%2Fextract-npm-package-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lutangar%2Fextract-npm-package-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lutangar","download_url":"https://codeload.github.com/lutangar/extract-npm-package-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242900001,"owners_count":20203704,"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":["config","env","npm","webpack"],"created_at":"2024-11-16T20:40:27.829Z","updated_at":"2026-05-02T11:39:44.938Z","avatar_url":"https://github.com/lutangar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# extract-npm-package-config\n\nThis package can extract npm package config variables from `process.env` for in-app usage.\n\nNpm per-package configuration setting is an *underrated* feature.\n\u003e https://docs.npmjs.com/misc/config#per-package-config-settings\n\n**package.json**\n```\n...\n  \"config\": {\n    \"scheme\": \"http\",\n    \"domain\": \"localhost\",\n    \"port\": \"3001\"\n  },\n...\n```\n1. As long as you use `npm run ...` scripts this config will be available in the `process.env` variables.\n2. Each of these variables can be referenced inside the `package.json` for usage with other scripts.\n3. Can easily be overridden via `env` variables server-side.\n\n# Install\n`npm install --save-dev extract-npm-package-config`\n\n# Usage\n\n## Standalone\n```\nimport extractPackageConfig from 'extract-npm-package-config';\n\nconst packageConfig = extractPackageConfig(process.env);\n```\n\u003e npm_package_config_domain: 'localhost' \n\u003e npm_package_config_port: 3000\n\n## Webpack\n\nIt can easily be used in conjunction with webpack [EnvironmentPlugin](https://webpack.js.org/plugins/environment-plugin/) client-side.\n\n**webpack.config.js**\n```\n...\nplugins: [\n    new webpack.EnvironmentPlugin(extractPackageConfig(process.env))\n]\n...\n```\n\n\u003e **Note 1:** You should'nt make use of it server side, because `weback.DefinePlugin` replace the variables in the source code itself,\n\u003ethus this would defeat the purpose of having `env` variables that can be easily overridden.\n\n\u003e **Note 2:** There is currently a limitation due to the way `weback.DefinePlugin` replace process.env occurrences in the code.\n\u003e You can't *destructure* `process.env` see https://github.com/webpack/webpack/issues/5392 \n\n\n# Licence\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flutangar%2Fextract-npm-package-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flutangar%2Fextract-npm-package-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flutangar%2Fextract-npm-package-config/lists"}