Skip to content

Reducing bundle size: globalThis.__DEV__ #2077

Closed Answered by PowerKiKi
damienwebdev asked this question in Ideas
Discussion options

You must be logged in to vote

Turning off development mode

Since angular/angular-cli@7f57123, so Angular 17.2, if you are using esbuild builder, then you can add this in your angular.json file:

--- angular.json
+++ angular.json
@@ -38,6 +38,9 @@
           },
           "configurations": {
             "production": {
+              "define": {
+                "globalThis.__DEV__": "false"
+              },
               "budgets": [
                 {
                   "type": "initial",

This will save about 6.6 kB, as seen below in a brand new, generated Angular app:

Before:

Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-GQVTFMH3.js      | main          | 414.74 kB |             …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@damienwebdev
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by PowerKiKi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants