Skip to content

added section on difference between building with or without prod flag #5195

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion docs/documentation/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,34 @@ ng build --bh /myUrl/
All builds make use of bundling, and using the `--prod` flag in `ng build --prod`
or `ng serve --prod` will also make use of uglifying and tree-shaking functionality.

**Note:** It is not recommended using `[class].constructor.name` while using the
`--prod` build flag. Since the name of the class will be uglified.
#### Example
```js
// Outputing router events to log
router.events.map(event => console.log(event.constructor.name));

// Output without --prod flag:
// NavigationStart
// RoutesRecognized
// NavigationEnd

// With --prod flag:
// t
// v
// c
```

#### Difference between building with or without `---prod` flag
The functionality that does not have * after it, are by default added to the workflow.

| | With | Without |
|--------------|:----:|:-------:|
| Tree-shaking | x | x* |
| Uglifying | x | |

*The flag must specifically be added.

## Options
`--aot` Build using Ahead of Time compilation.

Expand Down Expand Up @@ -107,4 +135,4 @@ or `ng serve --prod` will also make use of uglifying and tree-shaking functional

`--verbose` (`-v`) Adds more details to output logging.

`--watch` (`-w`) Run build when files change.
`--watch` (`-w`) Run build when files change.