Title: feat(serve): Add -main flag for entry point · Issue #3940 · angular/angular-cli · GitHub
Open Graph Title: feat(serve): Add -main flag for entry point · Issue #3940 · angular/angular-cli
X Title: feat(serve): Add -main flag for entry point · Issue #3940 · angular/angular-cli
Description: Feature requested Would like to be able to change the main entry point script to use via a flag when running ng serve (as well as ng build). ng serve -main main2.ts -e=someOtherEnvironment Reason While leveraging environment constants ar...
Open Graph Description: Feature requested Would like to be able to change the main entry point script to use via a flag when running ng serve (as well as ng build). ng serve -main main2.ts -e=someOtherEnvironment Reason W...
X Description: Feature requested Would like to be able to change the main entry point script to use via a flag when running ng serve (as well as ng build). ng serve -main main2.ts -e=someOtherEnvironment Reason W...
Opengraph URL: https://github.com/angular/angular-cli/issues/3940
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(serve): Add -main flag for entry point","articleBody":"## Feature requested\r\nWould like to be able to change the **main** entry point script to use via a flag when running `ng serve` (as well as `ng build`).\r\n```\r\nng serve -main main2.ts -e=someOtherEnvironment\r\n```\r\n## Reason\r\nWhile leveraging `environment` constants are handy to conditionally run code in your `main.ts` script, they don't get used by webpack (or AOT). So if you have some environment code that you don't want to include in your production build and you do the following in your `main.ts`:\r\n```\r\n. . .\r\nif (environment.someOtherEnvironment) {\r\n myBootstrap(); // This function has imports that bring in other non-production code\r\n} else {\r\n platformBrowserDynamic().bootstrapModule(AppModule);\r\n}\r\n```\r\nWebpack will follow that function and its imports and will add that code to the bundles even when you `ng serve` or `ng build`.\r\n\r\nHaving the ability to target different **main** scripts would allow for `ng serve` and `ng build` to be used to build the appropriate code.\r\n\r\nThen we could create different main files:\r\n**main.ts**\r\n```\r\n. . .\r\nplatformBrowserDynamic().bootstrapModule(AppModule);\r\n```\r\n**main.other.ts**\r\n```\r\n. . .\r\nmyBootstrap();\r\n```\r\nAnd achieve optimal bundling of our app code based on our intended environment.\r\n\r\n## Notes\r\nI'd be more than happy to add this feature, just want to confirm that it is something that people would feel would be worthy.\r\n\r\n@hansl @robwormald ","author":{"url":"https://github.com/jschwarty","@type":"Person","name":"jschwarty"},"datePublished":"2017-01-10T17:08:43Z","url":"https://github.com/angular/angular-cli/issues/3940"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c461dc55-137d-6b91-0ca1-f7bd8a32b0e5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A4F4:B142A:2B67F61:399D228:6B057194 |
| html-safe-nonce | 6872577556e7daadaf5670ffb0c7b5db770de0d2666eaa7a11551f927a884ddd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEY0OkIxNDJBOjJCNjdGNjE6Mzk5RDIyODo2QjA1NzE5NCIsInZpc2l0b3JfaWQiOiI5MDg3NzU5MzMwMDIyMTU4MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4a23aad8e620c7277d87f9c1ada89cc09e80f31e06b84d43d81c09534c016f1a |
| hovercard-subject-tag | issue:199879001 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/3940/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d0a94bc8d25ed4346cd766aa2b0725bbec9c1b33a503ada8556995586ee7c49/angular/angular-cli/issues/3940 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d0a94bc8d25ed4346cd766aa2b0725bbec9c1b33a503ada8556995586ee7c49/angular/angular-cli/issues/3940 |
| og:image:alt | Feature requested Would like to be able to change the main entry point script to use via a flag when running ng serve (as well as ng build). ng serve -main main2.ts -e=someOtherEnvironment Reason W... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jschwarty |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b4256ac5f3e310e7945ef5b71c9cb9e264357b1eb20e91d369ed6502a4c486c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f089e689ad324655ac44bf6cdbc04d976105b374 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width