{"id":15042577,"url":"https://github.com/sindresorhus/node-env-webpack-plugin","last_synced_at":"2025-10-19T19:30:47.113Z","repository":{"id":55410067,"uuid":"116017987","full_name":"sindresorhus/node-env-webpack-plugin","owner":"sindresorhus","description":"Simplified `NODE_ENV` handling with webpack","archived":false,"fork":false,"pushed_at":"2024-04-30T18:23:49.000Z","size":8,"stargazers_count":53,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-02T11:50:25.595Z","etag":null,"topics":["javascript","node-env","nodejs","npm-package","webpack","webpack-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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"},"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":"2018-01-02T13:28:30.000Z","updated_at":"2024-04-30T18:23:53.000Z","dependencies_parsed_at":"2024-05-01T20:37:26.232Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/node-env-webpack-plugin","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":"0.19999999999999996","last_synced_commit":"8446a19f8daef20237902ab871cbd5d9cda1e32d"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fnode-env-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fnode-env-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fnode-env-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fnode-env-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/node-env-webpack-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":200648300,"owners_count":13759962,"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":["javascript","node-env","nodejs","npm-package","webpack","webpack-plugin"],"created_at":"2024-09-24T20:47:32.011Z","updated_at":"2025-10-19T19:30:41.830Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# node-env-webpack-plugin\n\n\u003e Simplified `NODE_ENV` handling with [webpack](https://webpack.js.org)\n\n## Install\n\n```sh\nnpm install node-env-webpack-plugin\n```\n\n## Usage\n\n```diff\n  import path from 'node:path';\n+ import NodeEnvPlugin from 'node-env-webpack-plugin';\n\n- const NODE_ENV = process.env.NODE_ENV || 'development';\n- const isProduction = NODE_ENV === 'production';\n\n  module.exports = {\n  \tentry: './source',\n  \toutput: {\n  \t\tpath: path.join(__dirname, 'distribution'),\n  \t\tfilename: 'bundle.js'\n  \t},\n- \tdevtool: isProduction ? 'source-map' : 'cheap-module-source-map',\n+ \tdevtool: NodeEnvPlugin.devtool,\n  \tmodule: {\n  \t\trules: [\n  \t\t\t{\n  \t\t\t\ttest: /\\.js$/,\n  \t\t\t\texclude: /node_modules/,\n  \t\t\t\tloader: 'babel-loader'\n  \t\t\t}\n  \t\t]\n  \t},\n  \tplugins: [\n- \t\tnew webpack.EnvironmentPlugin({\n- \t\t\tNODE_ENV: 'development'\n- \t\t}),\n+ \t\tnew NodeEnvPlugin()\n  \t]\n  };\n```\n\n## API\n\nSets `process.env.NODE_ENV` in the Node.js process to `development` at import-time if it's not defined, or `production` if webpack is run with `webpack -p`.\n\n### NodeEnvPlugin()\n\nSets `process.env.NODE_ENV` in the bundle to the same as in the Node.js process.\n\n### NodeEnvPlugin.isProduction\n\nFor convenience and to prevent typos.\n\n`process.env.NODE_ENV === 'production'`\n\n### NodeEnvPlugin.isDevelopment\n\n`process.env.NODE_ENV === 'development'`\n\n### NodeEnvPlugin.isTest\n\n`process.env.NODE_ENV === 'test'`\n\n### NodeEnvPlugin.devtool\n\nPass this to the webpack `devtool` option. It will give you good but slow source maps in production (`source-map`) and fast source maps in development (`cheap-module-source-map`).\n\n## Related\n\n- [add-asset-webpack-plugin](https://github.com/sindresorhus/add-asset-webpack-plugin) - Dynamically add an asset to the webpack graph\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fnode-env-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fnode-env-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fnode-env-webpack-plugin/lists"}