{"action":"created","issue":{"url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter/issues/386","repository_url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter","labels_url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter/issues/386/labels{/name}","comments_url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter/issues/386/comments","events_url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter/issues/386/events","html_url":"https://github.com/AngularClass/angular2-webpack-starter/issues/386","id":138629809,"number":386,"title":"Best way to pass variables through Webpack?","user":{"login":"louisscruz","id":7310102,"avatar_url":"https://avatars.githubusercontent.com/u/7310102?v=3","gravatar_id":"","url":"https://api.github.com/users/louisscruz","html_url":"https://github.com/louisscruz","followers_url":"https://api.github.com/users/louisscruz/followers","following_url":"https://api.github.com/users/louisscruz/following{/other_user}","gists_url":"https://api.github.com/users/louisscruz/gists{/gist_id}","starred_url":"https://api.github.com/users/louisscruz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louisscruz/subscriptions","organizations_url":"https://api.github.com/users/louisscruz/orgs","repos_url":"https://api.github.com/users/louisscruz/repos","events_url":"https://api.github.com/users/louisscruz/events{/privacy}","received_events_url":"https://api.github.com/users/louisscruz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-03-05T01:20:38Z","updated_at":"2016-11-21T03:59:39Z","closed_at":null,"body":"Simple question, but I'm a little lost with the way `webpack.DefinePlugin` interacts with the application. \n\nFor my `http` calls, I'd like to have a variable that is dynamic based on the `process.env.ENV`. What's the best way to define a variable in both my webpack.config.js and webpack.prod.config.js files? And what's the best way to make them global variables in the application?\n"},"comment":{"url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter/issues/comments/261837172","html_url":"https://github.com/AngularClass/angular2-webpack-starter/issues/386#issuecomment-261837172","issue_url":"https://api.github.com/repos/AngularClass/angular2-webpack-starter/issues/386","id":261837172,"user":{"login":"nmccready","id":583593,"avatar_url":"https://avatars.githubusercontent.com/u/583593?v=3","gravatar_id":"","url":"https://api.github.com/users/nmccready","html_url":"https://github.com/nmccready","followers_url":"https://api.github.com/users/nmccready/followers","following_url":"https://api.github.com/users/nmccready/following{/other_user}","gists_url":"https://api.github.com/users/nmccready/gists{/gist_id}","starred_url":"https://api.github.com/users/nmccready/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmccready/subscriptions","organizations_url":"https://api.github.com/users/nmccready/orgs","repos_url":"https://api.github.com/users/nmccready/repos","events_url":"https://api.github.com/users/nmccready/events{/privacy}","received_events_url":"https://api.github.com/users/nmccready/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T03:59:39Z","updated_at":"2016-11-21T03:59:39Z","body":"> @marek1 I noticed the same, there is a strange behaviour: When I de console.log(process) there is an empty env object .\r\n\r\nThis strange behavior becomes clear when you look at the packed webpack file. Basically process does not get added to the global scope what so ever. Webpack does a search and replace for anything that is process.env and fills it in with that object specifically everywhere. So essentially it is a new instance of that config object every time. I think this was to not pollute the global space, but for minify purposes seems like a waste.\r\n\r\nIs there a option to make it part of the global namespace?\r\n\r\n\r\nExample:\r\n\r\n```js\r\nnew webpack.DefinePlugin({\r\n  '__PROCESS__': {\r\n    'ENV': 'production',\r\n  }\r\n})\r\n```\r\n\r\nclient code (source mapped):\r\n```js\r\nif(__PROCESS__.ENV === 'production'){\r\n//do something\r\n}\r\n```\r\n\r\nReal Packed Code:\r\n\r\nclient code (source mapped):\r\n```js\r\nif(({\"ENV\":\"production\"}).ENV === 'production'){\r\n//do something\r\n}\r\n```\r\n\r\nIt is not what you assumed it was \r\n```js\r\nwindow.__PROCESS = {\"ENV\":\"production\"};\r\n```"}}
{"actor":{"display_login":"nmccready"}}