π» Lab 3 - Executors
December 9, 2021 Β· View on GitHub
β° Estimated time: 5-15 minutes
We'll build the app we just created, and look at what executors are and how to customize them.
π Learning outcomes:
- Understand what a
targetandexecutorare - Learn how to invoke executors
- Configure executors by passing them different options
- Understand how an executor can invoke another executor
π² After this workshop, you should have:
App Screenshot
File structure
ποΈββοΈ Steps:
-
Build the app
π³ Hint
-
You should now have a
distfolder - let's open it up!- This is your whole app's output! If we wanted we could push this now to a server and it would all work.
- This is your whole app's output! If we wanted we could push this now to a server and it would all work.
-
Open up
apps/store/project.jsonand look at the object undertargets/build- this is the target, and it has a executor option, that points to
@angular-devkit/build-angular:browser - Remember how we copied some images into our
/assetsfolder earlier? Look through the executor options and try to find how it knows to include them in the final build!
- this is the target, and it has a executor option, that points to
-
Notice the
defaultConfigurationexecutor option is pointing toproduction. This means it applies all the prod optimisations to our outputs, as per theproductionconfiguration inproject.json. Send a flag to the executor so that it builds for development instead.π³ Hint
--configuration=development
-
Open up the
distfolder again - notice how all the file names have no hashes, and the contents themselves are human readable.
-
Modify
project.jsonand instruct the executor to import the Angular Material styles:./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.cssπ³ Hint
Add it to:
"styles": ["apps/store/src/styles.css"]πNotice how we can configure executors by either modifying their options in
project.json(this step) or through the command line (step 4)!
-
The serve target (located a bit lower in
project.json) also contains a executor, that uses the output from the build target we just changed (seeserve --> options --> browserTarget--> it points to thebuildtarget of thestoreproject)- so we can just re-start
nx serve storesee the new styles you added!
- so we can just re-start
-
Inspect what changed from the last time you committed, then commit your changes
πIf you get stuck, check out the solution