-
Notifications
You must be signed in to change notification settings - Fork 12k
in angular.json buildOptimizer not allowed to be set for "serve" #17473
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
Comments
Hi @freed00m, I think this is expected.
My suggestion would be to use multiple configurations examples; "serve": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
...
},
"configurations": {
"production": {
"aot": true,
"optimization": true,
"buildOptimizer": true,
"sourceMap": false
...
},
"demo": {
"buildOptimizer": true,
"optimization": false,
"aot": false,
"sourceMap": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "frontend:build",
"baseHref": "/app/"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
},
"demo": {
"browserTarget": "frontend:build:production,demo",
}
}
}, More info: https://angular.io/guide/workspace-config#alternate-build-configurations I am going to mark this issue as needs further discussion to see if we should do anything about the |
I tried to avoid multiple configurations, since they share so much, except the aot and optimization. But maybe you are correct to not allow it. I just got bitten with aot = true in "serve" and was getting mad why my rebuilding takes so long. I have a long "fileReplace" list and didn't want to keep two copies in two similar configurations. sidenote - My desire is to have demo serve fast as the regular defaults are, but demo "build" should produce optimized aot builds as production does. Cannot do it now without 2 configuration |
You don't need to duplicate the "common" configuration options such as NB: in version 9 |
I am still confused.
So --configuration=production,demo will still end up with aot + optimization in ng serve demo, however I will create a third configuration that will only disable the aot+optimization a will have something like --configuration=production,demo,aotoff
Yes you are correct I might start using aot in serve also without optimization. |
Note: we should work on a design doc and decide which build specific options to remove from the dev-server build such as Users are encouraged to use different configurations |
@alan-agius4 It is a pity that the merge #17713 is closed and that this flexibility does not fit in the roadmap. We are already using the configurations very intensively. We have setups that exists of upto 16 different configurations. Think of multiple organization theming, otap and app vs web configuration. Now we have to add even more configuration. Because we cannot do overingen for temporarily disable the optimizations from the cli when doing debugging. |
@Heerschop, it would be interesting to see what sort of configurations you are using to see, if they can be reduced/split. Are you using multiple named configurations? as described #17473 (comment) and https://angular.io/guide/workspace-config#alternate-build-configurations |
@alan-agius4 this is an application that we have to deploy in 16 different configurations The application is targeted to the web as PWA and targeted to the phone as a Cordova-app. This has to be done for two organizations with their own styling. For this we use 4 different projects, the project are manly used for file copies like assets, icons, service workers, styles etc. Which can be different depending on the organization or if it's on the phone or the web. Each project contains 4 different configurations for the staging environments. The configurations are mostly simple file replacement of the For debug, it's really nice if we can temporarily overrule the configuration settings, that speeds up debugging in a production configuration. Of course, we can add an extra configuration for this, but we prefer not to. |
@Heerschop, you should use the new-ish multiple configurations feature. These are applied from left to right and allow you to override options like this: ng build -c brand-one
ng build -c production,brand-one
ng build -c production,brand-one,debug
ng serve -c production,brand-two,debug
// Or
ng build -c production,brand-one-staging,debug
ng build -c production,brand-one-uat,debug Here, you basically provide the default production flags in the production config, then for each environment you override the files, but if you want a debug mode, you just add an extra BUT, the application configuration that varies between environments like staging, UAT and production, should be outside of the application bundle. You should set the API endpoint when you deploy the application, not when you build it, see #17786 |
@SchnWalter This is a nice and clean solution for my problem. |
Hi @Heerschop, you don't need to create configurations in serve to use build configurations in the dev-server builder. You can use
The command is a bit more verbose, but you won't need to include extra configurations in |
@freed00m, I see that you've reacted to some of the suggestions above. Do the last couple of suggestions work for you? If so, can you please close this issue? Thanks! |
@SchnWalter yes, sorry I was not sure if there is anything more to be discussed. |
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. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
No, I think it is simple oversight in angular.json schemaDescription
Cannot disable AOT for serve if buildOptimizer set to true.
due to
buildOptimizer is illegal option in serve
🔬 Minimal Reproduction
I've created a custom configuration
but for serving I want to turn of AOT, which is
I could do
but that will fail, because the "buildOptimize" is true, and is not allowed to be set in serve configuration
🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: