Building your React app with Nx

Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

At some point you definitely want to build and deploy your app. Obviously, Nx got your back as well. In this lesson we're going to explore the command & configuration for producing a deployable bundle. We'll go through some of the options and learn about the --configuration=production configuration.

Instructor: [0:00] Once we have our applications living in our Nx workspace, we obviously also want to build and deploy them. You can always go into the workspace.json and inspect what kind of targets you'll have available within that architect node, which is the main node for doing the whole things about building, testing, linting, and other things as well.

[0:21] In our case, if we look at the store application, we can see that we have that build target in here and the build target has a variety of options, which depend on which framework you're using for developing that store application. In this case, we have a React application. These are the options that are being passed in. You can also modify these to your own needs and adjust them as you want.

[0:43] Furthermore, we have different kinds of configurations. In this case, you can see we have a production configuration. You could add different ones and whenever we pass in the production configuration, we'll go and take these parameters and override the default ones which are specified in that builder options.

[0:59] The output path here is the dist directory. Let's quickly open up our terminal and invoke that target. Again, as we did in the previous videos, let's use nx run store and there we use the --target=build and we pass also in the --configuration=production, which we'll use our production configuration on here and produce a more optimized, build bundle.

[1:21] Once this is done, if we go to the dist directory, we can see here app store and we have a variety of assets and all the static files that can be deployed. Now, since the build target is something that you might use more often, you can also use the actual nx build command rather than using nx run and just give it a store. Again, we can use --configuration=production, and build the exact same thing.

[1:45] Also, since we also have the API in here, we can do the exact same for API. We can just use here build, the name of the project here is API. Again, we can deduct that here from the project. If we close this here, the end-to-end tests, then we will see further down here, there is the API node.

[2:04] We can use that one here as the target to invoke to build on, and then we just use nx build API --configuration=production and in the very same fashion, in the dist directory we'll also have now the deployables for our API.

egghead
egghead
~ 44 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today