- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 566
 
Speed up buildings (for persons who has many posts)
        Hiroki Toyokawa edited this page May 20, 2023 
        ·
        2 revisions
      
    This section explains to speed up buildings for persons who has many posts.
- Run the following command to generate an access token of Nx Cloud
 
npm install && npx nx g @nrwl/nx-cloud:init- Note the value of 
accessTokeninnx.jsonin the project root - Run the following command to delete 
accessTokenfromnx.json 
git checkout -- nx.json- Open Nx Cloud in a browser and sign up and sign in
 - Select "Connect a Workspace"
 
- Select "Yes, I'm using @nrwl/nx-cloud" at "01 Check for Nx Cloud package"
 
- Select "Connect The Workspace" at "03 Setup The Access Token" and input the value of 
accessTokenwhich you noted before 
- Select "View Your Workspace" and go back to the terminal
 - Confirm 
NOTION_API_SECRETis set to an environment variable properly 
echo $NOTION_API_SECRETIf not so, set your Notion API secret.
export NOTION_API_SECRET=<YOUR_NOTION_API_SECRET>- Confirm 
DATABASE_IDenvironment variable is equivalent with the Cloudflare Pages building environment 
echo $DATABASE_IDSet the same value if it's not same.
export DATABASE_ID=<YOUR_DATABASE_ID>- Set the value of 
accessTokenwhich you noted before to an environment variable asNX_CLOUD_ACCESS_TOKEN, and confirm it 
export NX_CLOUD_ACCESS_TOKEN=<The value of accessToken>
echo $NX_CLOUD_ACCESS_TOKEN- Run the following command to generate the caches
 
npm run cache:fetch- Run the command again to confirm whether the caches are generated (if the caches are generated properly, the command will be done faster than previous)
 
- The caches will be updated automatically if 
last_edited_timeof Notion Page are changed so you don't need to run the command after this confirmation 
npm run cache:fetch- Open Nx Cloud in a browser and confirm whether the result is "Local Cache Hit"
 
- Open Cloudflare Pages and go to "Environment variables", set the value of 
accessTokenasNX_CLOUD_ACCESS_TOKENinto both Production and Preview 
- Go to the build settings
 
- Change "Build command" as the following and save
 
npm run build:cached
- Push the branch to GitHub to deploy, and go to Nx Cloud to confirm whether the result is "Remote Cache Hit"