New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(@schematics/angular): remove environment files in new applications #23931
feat(@schematics/angular): remove environment files in new applications #23931
Conversation
ecdb2f0
to
87fb244
Compare
blocked on angular/angular#47475 |
Hi, Maybe better documentation and schematics to generate this stuff would be a great replacement? |
Please don't do this. Some of us are using fileReplacements for other things (related to i18n), and having 2 separate configs is very convenient. |
Echoing above sentiments, please don't do this, ie. fix what's not broken. A lot of developers (including myself) depend on this critical feature. Taking it away for no good end-user facing reason would be a shame and a big red flag for me. |
I can only see these environment files and corresponding fileReplacements removed if there will be a generator that can scaffold this feature on-demand |
Truthfully, I'll be the dissenting voice to many of the "Don't do this" comments here. While I'm in favor of not removing these features full-stop, I think the less code we can have in Regularly, I find those that are learning frameworks like Angular asking "What do these configuration options mean?" and getting lost in a lot of the noise. I think this will go a long way in helping build trust with those that are learning for the first time, or even those of us that don't regularly configure environment files. |
@alan-agius4 I assume this PR is about taking out this feature from newly generated projects? Disabling this option for existing projects will be a big breaking change. And there are still good uses for those things to exist. |
@SanderElias if something is discouraged from use - it will be deprecated and then removed. Usually it works this way :) |
As others have mentioned, removing environment files is a terrible idea since this a great feature and this PR will hurt its discoverability. How about something else instead: At my work we've started a new pattern. The default prod/dev configurations are very vague when it comes to the meaning they convey. I see a lot of projects associate bundle optimization configurations and the environment configurations under the same flag - dev or prod.
The This way we have a few scripts we use, but we can also easily run commands mixing and matching these configuration settings: {
"start": "ng serve -c env-dev,optimizations-off",
"build-beta": "ng build -c=env-beta,optimizations-on",
// ... etc
} That's the change I'd rather see in new application out of the box. Heck, I guess it could have been a separate feature request... |
I am with removing it because it's not the only solution to provide env variables and I always thought that Angular force us to use this approach... Personally, I prefer to inject a json file for prod/staging env and I hard coded the variables for dev env if no json provided. Like this I can use the same version for my app in many environments without rebuilding it to add a new env. |
Thank you all for the feedback. The There are 2 parts to this change, both of which are for new applications.
Users wishing to use the |
I think when creating a project the cli could ask the user if they want an environment file, just like the cli asks which css preprocessor I want. |
@alan-agius4 already added some details, but just to elaborate a little more: To be very clear to those skimming the PR environment files are not being removed, deprecated, or discouraged. They solve very real problems for users and we have no plans to drop that particular feature. What this PR does is remove some unnecessary boilerplate in The goal here is to reduce the complexity of the generated We do recognize that not generating environments by default does impact discoverability and usability. This is something we think can be improved in documentation and tutorials, as well as some improved schematics. We feel these are solvable problems without impacting a new developer's experience getting started with Angular. Hopefully that clarifies our intent and can alleviate some concerns in the community. As we get closer to v15 we'll have more conversations within the community about this approach. Folks watching PRs are just getting an early glimpse into things we haven't figured out all our communications for just yet. So look forward to more discussion and insight in the future. |
87fb244
to
71c090e
Compare
db76dd2
to
016558c
Compare
packages/schematics/angular/application/files/src/main.ts.template
Outdated
Show resolved
Hide resolved
016558c
to
548c939
Compare
This commit removes the usage of environment files and `fileReplacements` in new application projects. Previously, the environment files was used to distinguish between a prod build to invoke `enableProdMode`. The `enableProdMode` however needed only for the case of JIT mode in production mode, which is a rare case as JIT mode is recommanded to be used in production. In the CLI, calling `enableProdMode` is not needed as `ngDevMode` it's set using the minifier.
548c939
to
e271e11
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit removes the usage of environment files and
fileReplacements
in new application projects. Previously, the environment files was used to distinguish between a prod build to invokeenableProdMode
. TheenableProdMode
however needed only for the case of JIT mode in production mode, which is a rare case as JIT mode is recommanded to be used in production.In the CLI, calling
enableProdMode
is not needed asngDevMode
/isDevMode
is set using the minifier. See: angular/angular#47475This change only affects newly applications generated by
ng new
/ng generate application
. Environments are not being removed, deprecated, or discouraged.