Skip to content

Commit 154f943

Browse files
Reviews and screenshots
1 parent 6b9cfbc commit 154f943

File tree

8 files changed

+77
-79
lines changed

8 files changed

+77
-79
lines changed

articles/static-apps/deploy-nextjs.md

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ In this tutorial, you learn to deploy a [Next.js](https://nextjs.org) generated
2424

2525
Rather than using the Next.js CLI to create an app, you can use a starter repository that includes an existing Next.js app. This repository features a Next.js app with dynamic routes, which highlights a common deployment issue. Dynamic routes need an extra deployment configuration which you will learn more about in a moment.
2626

27-
1. Clone starter repository:
27+
1. Create a new repository under your GitHub account from a template repository.
28+
1. Navigate to <http://github.com/staticwebdev/nextjs-starter/generate>
29+
1. Name the repository **nextjs-starter**
30+
1. Next, clone the new repo to your machine. Make sure to replace <YOUR_GITHUB_ACCOUNT_NAME> with your account name.
2831

29-
```bash
30-
git clone https://github.com/christiannwamba/nextjs-static-websites-starter
31-
```
32+
```bash
33+
git clone http://github.com/<YOUR_GITHUB_ACCOUNT_NAME>/nextjs-starter
34+
```
3235

3336
1. Navigate to the newly cloned Next.js app:
3437

3538
```bash
36-
cd nextjs-static-websites-starter
39+
cd nextjs-starter
3740
```
3841

3942
1. Install dependencies:
@@ -48,7 +51,7 @@ Rather than using the Next.js CLI to create an app, you can use a starter reposi
4851
npm run dev
4952
```
5053

51-
You should see the following website open in your preferred browser:
54+
Navigate to <http://localhost:3000> to open the app, where you should see the following website open in your preferred browser:
5255

5356
![Start Next.js app](./media/deploy-nextjs/start-nextjs-app.png)
5457

@@ -60,7 +63,7 @@ When you click on a framework/library, you should see a details page about the s
6063

6164
When you build a Next.js site using `npm run build`, the app is built as a traditional web app, not a static site. To generate a static site, use the following application configuration.
6265

63-
1. To configure static routes, create file named _next.config.js_ at the root of your project.
66+
1. To configure static routes, create file named _next.config.js_ at the root of your project and add the following code..
6467

6568
```javascript
6669
module.exports = {
@@ -99,53 +102,41 @@ When you build a Next.js site using `npm run build`, the app is built as a tradi
99102
100103
## Push your static website to GitHub
101104
102-
Azure Static Web Apps deploys your app from a GitHub repository and keeps doing so for every pushed commit to a designated branch. Use the following command to set up a repository.
103-
104-
1. Initialize a git repo
105+
Azure Static Web Apps deploys your app from a GitHub repository and keeps doing so for every pushed commit to a designated branch. Use the following commands sync your changes to GitHub.
105106
107+
1. Stage all changed files
106108
```bash
107-
# Remove existing .git
108-
rm -rf .git
109-
# Initialize git
110-
git init
111-
# Add all files
112109
git add .
113-
# Commit changes
114-
git commit -m "initial commit"
115110
```
116-
117-
1. Create a blank GitHub repo (don't create a README) from [https://github.com/new](https://github.com/new) and name it whatever you like for example, **nextjs-static-website**.
118-
119-
1. Add the GitHub repo as a remote to your local repo.
120-
111+
1. Commit all changes
121112
```bash
122-
git remote add origin https://github.com/<YOUR_USER_NAME>/<YOUR_REPO_NAME>
113+
git commit -m "Update build config"
123114
```
124115
125-
1. Push your local repo up to GitHub.
116+
1. Push your changes to GitHub.
126117
127118
```bash
128-
git push --upstream origin master
119+
git push origin master
129120
```
130121
131122
## Deploy your static website
132123
133-
The following steps show how to deploy the app you just pushed to GitHub to Azure Static Web Apps. Once in Azure you can deploy the application to a production environment.
124+
The following steps show how to link the app you just pushed to GitHub to Azure Static Web Apps. Once in Azure you can deploy the application to a production environment.
134125
135126
### Create Azure App Service Static App
136127
137128
1. Navigate to the [Azure Portal](https://portal.azure.com).
138129
1. Click **Create a Resource** then search for **Static Web Apps** and select the matching result.
139130
140-
[Image of Static App]
131+
<!--- TODO: Add screenshot for navigating to static web apps --->
141132
142-
1. Select a subscription from the *Subscription* dropdown list or use the default one.
143-
1. Click the **New** link below the *Resource group* dropdown. In *New resource group name*, type **nextjsstaticsite** and click **OK**
133+
1. Select a subscription from the *Subscription* drop-down list or use the default value.
134+
1. Click the **New** link below the *Resource group* drop-down. In *New resource group name*, type **mystaticsite** and click **OK**
144135
1. Provide a globally unique name for your app in the **Name** text box. Valid characters include `a-z`, `A-Z`, `0-9`, and `-`. This value is used as the URL prefix for your static app in the format of `https://<APP_NAME>.azurestaticapps.net`.
145136
1. In the *Region* drop-down, choose a region closest to you.
146137
1. Select **Free** from the SKU drop-down.
147138
148-
[Image of static app form]
139+
![Create Static Web App](./media/deploy-nextjs/create-static-web-app.png)
149140
150141
### Add a GitHub repository
151142
@@ -156,15 +147,15 @@ The new Static Web Apps account needs access to the repository with your Next.js
156147
1. Find and select the name of the repository you created earlier.
157148
1. Choose **master** as the branch from the *Branch* drop-down.
158149
159-
[Image of new repo form]
150+
![Connect GitHub](./media/deploy-nextjs/connect-github.png)
160151
161152
### Configure the build process
162153
163154
Azure Static Web Apps is built to automatically carry out common tasks like installing npm modules and running `npm run build` during each deployment. There are, however, a few settings like the application source folder and the build destination folder that you need to configure manually.
164155
165156
1. Click on the **Build** tab to configure the static output folder.
166157
167-
[Image highlighting the Build tab]
158+
![Build tab](./media/deploy-nextjs/build-tab.png)
168159
169160
1. Type **out** in the *App artifact location* text box.
170161
@@ -173,7 +164,21 @@ Azure Static Web Apps is built to automatically carry out common tasks like inst
173164
1. Click the **Review + Create** button to verify the details are all correct.
174165
1. Click **Create** to start the creation of the resource and also provision a GitHub Action for deployment.
175166
1. Once the deployment is completed, click **Go to resource**
176-
1. On the resource screen, click the *URL* link to open your deployed application.
167+
1. On the _Overview_ window, click the *URL* link to open your deployed application.
168+
169+
If the website does note immediately load, then the background GitHub Actions workflow is still running. Once the workflow is complete you can then click refresh the browser to view your web app.
170+
171+
You can check the status of the Actions workflows by navigating to the Actions for your repository:
172+
173+
```bash
174+
https://github.com/<YOUR_GITHUB_USERNAME>/nextjs-starter/actions
175+
```
176+
177+
### Sync changes
178+
179+
When you created the app, Azure Static Web Apps created a GitHub Actions workflow file in your repository. You need to bring this file down to your local repository so your git history is synchronized.
180+
181+
Return to the terminal and run the following command `git pull origin maser`.
177182
178183
## Configure dynamic routes
179184
@@ -183,17 +188,6 @@ Navigate to the newly-deployed site and click on one of the framework or library
183188
184189
The reason for this error is because Next.js only generated the home page based on the application configuration.
185190
186-
```javascript
187-
module.exports = {
188-
exportTrailingSlash: true,
189-
exportPathMap: function() {
190-
return {
191-
'/': { page: '/' }
192-
};
193-
}
194-
};
195-
```
196-
197191
## Generate static pages from dynamic routes
198192
199193
1. Update the _next.config.js_ file so that Next.js uses a list of all available data to generate static pages for each framework/library:
@@ -224,7 +218,7 @@ module.exports = {
224218
> [!NOTE]
225219
> The `exportPathMap` function is an async function, so you can make a request to an API in this function and use the returned list to generate the paths.
226220
227-
1. Push the new changes to your GitHub repository and wait for a few minutes while GitHub Actions builds your site again. After the build is complete, the 404 error disappears.
221+
2. Push the new changes to your GitHub repository and wait for a few minutes while GitHub Actions builds your site again. After the build is complete, the 404 error disappears.
228222
229223
![404 on dynamic routes fixed](./media/deploy-nextjs/404-in-production-fixed.png)
230224

articles/static-apps/deploy-nuxtjs.md

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ In this tutorial, you learn to deploy a [Nuxt.js](https://nuxtjs.org) generated
2323

2424
You can set up a new Nuxt.js project using `create-nuxt-app`. Instead of a new project, let's clone a repository that is set up to demonstrate an edge case when you try to deploy a dynamic Nuxt.js app. The repository contains an example of a dynamic site that we want to serve as a static site.
2525

26-
1. Clone starter repository:
26+
1. Create a new repository under your GitHub account from a template repository.
27+
1. Navigate to <http://github.com/staticwebdev/nuxtjs-starter/generate>
28+
1. Name the repository **nuxtjs-starter**
29+
1. Next, clone the new repo to your machine. Make sure to replace <YOUR_GITHUB_ACCOUNT_NAME> with your account name.
2730

28-
```bash
29-
git clone https://github.com/christiannwamba/nuxtjs-static-website-starter
30-
```
31+
```bash
32+
git clone http://github.com/<YOUR_GITHUB_ACCOUNT_NAME>/nuxtjs-starter
33+
```
3134

3235
1. Navigate to the newly cloned Nuxt.js app:
3336

3437
```bash
35-
cd nuxtjs-static-website-starter
38+
cd nuxtjs-starter
3639
```
37-
3840
1. Install dependencies:
3941

4042
```bash
@@ -47,7 +49,7 @@ You can set up a new Nuxt.js project using `create-nuxt-app`. Instead of a new p
4749
npm run dev
4850
```
4951

50-
You should see the following website open in your preferred browser:
52+
Navigate to <http://localhost:3000> to open the app, where you should see the following website open in your preferred browser:
5153

5254
![Start Nuxt.js app](./media/deploy-nuxtjs/start-nuxtjs-app.png)
5355

@@ -83,53 +85,41 @@ When you build a Nuxt.js site using `npm run build`, the app is built as a tradi
8385
8486
## Push your static website to GitHub
8587
86-
Azure Static Web Apps deploys your app from a GitHub repository and keeps doing so for every pushed commit to a designated branch. Use the following command to set up a repository.
87-
88-
1. Initialize a git repo
88+
Azure Static Web Apps deploys your app from a GitHub repository and keeps doing so for every pushed commit to a designated branch. Use the following commands sync your changes to GitHub.
8989
90+
1. Stage all changed files
9091
```bash
91-
# Remove existing .git
92-
rm -rf .git
93-
# Initialize git
94-
git init
95-
# Add all files
9692
git add .
97-
# Commit changes
98-
git commit -m "initial commit"
9993
```
100-
101-
1. Create a blank GitHub repo (don't create a README) from [https://github.com/new](https://github.com/new) and name it whatever you like for example, **nuxtjs-static-website**.
102-
103-
1. Add the GitHub repo as a remote to your local repo.
104-
94+
1. Commit all changes
10595
```bash
106-
git remote add origin https://github.com/<YOUR_USER_NAME>/<YOUR_REPO_NAME>
96+
git commit -m "Update build config"
10797
```
10898
109-
1. Push your local repo up to GitHub.
99+
1. Push your changes to GitHub.
110100
111101
```bash
112-
git push --upstream origin master
102+
git push origin master
113103
```
114104
115105
## Deploy your static website
116106
117-
The following steps show how to deploy the app you just pushed to GitHub to Azure Static Web Apps. Once in Azure you can deploy the application to a production environment.
107+
The following steps show how to link the app you just pushed to GitHub to Azure Static Web Apps. Once in Azure you can deploy the application to a production environment.
118108
119109
### Create Azure App Service Static App
120110
121111
1. Navigate to the [Azure Portal](https://portal.azure.com).
122112
1. Click **Create a Resource** then search for **Static Web Apps** and select the matching result.
123113
124-
[Image of Static App]
114+
<!--- TODO: Add screenshot for navigating to static web apps --->
125115
126-
1. Select a subscription from the *Subscription* dropdown list or use the default one.
127-
1. Click the **New** link below the *Resource group* dropdown. In *New resource group name*, type **nuxtjsstaticsite** and click **OK**
116+
1. Select a subscription from the *Subscription* drop-down list or use the default value.
117+
1. Click the **New** link below the *Resource group* drop-down. In *New resource group name*, type **mystaticsite** and click **OK**
128118
1. Provide a globally unique name for your app in the **Name** text box. Valid characters include `a-z`, `A-Z`, `0-9`, and `-`. This value is used as the URL prefix for your static app in the format of `https://<APP_NAME>.azurestaticapps.net`.
129119
1. In the *Region* drop-down, choose a region closest to you.
130120
1. Select **Free** from the SKU drop-down.
131121
132-
[Image of static app form]
122+
![Create Static Web App](./media/deploy-nuxtjs/create-static-web-app.png)
133123
134124
### Add a GitHub repository
135125
@@ -140,15 +130,15 @@ The new Static Web Apps account needs access to the repository with your Nuxt.js
140130
1. Find and select the name of the repository you created earlier.
141131
1. Choose **master** as the branch from the *Branch* drop-down.
142132
143-
[Image of new repo form]
133+
![Connect GitHub](./media/deploy-nuxtjs/connect-github.png)
144134
145135
### Configure the build process
146136
147137
Azure Static Web Apps is built to automatically carry out common tasks like installing npm modules and running `npm run build` during each deployment. There are, however, a few settings like the application source folder and the build destination folder that you need to configure manually.
148138
149139
1. Click on the **Build** tab to configure the static output folder.
150140
151-
[Image highlighting the Build tab]
141+
![Build tab](./media/deploy-nuxtjs/build-tab.png)
152142
153143
1. Type **dist** in the *App artifact location* text box.
154144
@@ -157,7 +147,21 @@ Azure Static Web Apps is built to automatically carry out common tasks like inst
157147
1. Click the **Review + Create** button to verify the details are all correct.
158148
1. Click **Create** to start the creation of the resource and also provision a GitHub Action for deployment.
159149
1. Once the deployment is completed, click **Go to resource**
160-
1. On the resource screen, click the *URL* link to open your deployed application.
150+
1. On the _Overview_ window, click the *URL* link to open your deployed application.
151+
152+
If the website does note immediately load, then the background GitHub Actions workflow is still running. Once the workflow is complete you can then click refresh the browser to view your web app.
153+
154+
You can check the status of the Actions workflows by navigating to the Actions for your repository:
155+
156+
```bash
157+
https://github.com/<YOUR_GITHUB_USERNAME>/nuxtjs-starter/actions
158+
```
159+
160+
### Sync changes
161+
162+
When you created the app, Azure Static Web Apps created a GitHub Actions workflow file in your repository. You need to bring this file down to your local repository so your git history is synchronized.
163+
164+
Return to the terminal and run the following command `git pull origin maser`.
161165
162166
## Configure dynamic routes
163167
@@ -198,7 +202,7 @@ If the page is a dynamic page, for example `_id.vue`, it won't have enough infor
198202
> [!NOTE]
199203
> `routes` is an async function, so you can make a request to an API in this function and use the returned list to generate the paths.
200204
201-
1. Push the new changes to your GitHub repository and wait for a few minutes while GitHub Actions builds your site again. After the build is complete, the 404 error disappears.
205+
2. Push the new changes to your GitHub repository and wait for a few minutes while GitHub Actions builds your site again. After the build is complete, the 404 error disappears.
202206
203207
![404 on dynamic routes fixed](./media/deploy-nuxtjs/404-in-production-fixed.png)
204208
70.5 KB
Loading
227 KB
Loading
201 KB
Loading
70.5 KB
Loading
227 KB
Loading
201 KB
Loading

0 commit comments

Comments
 (0)