Build Your Loop
Once you have your Loop created (even if it is just the sample code), you will need to build the Loop out -- here are some steps to help.
Environment
Install Node.js, or install/use a version manager like NVM. (We recommend using the current LTS version (at the time of writing, that is some flavor of v14).
Open PowerShell or a Terminal (or any other prompt of choice). Double check your installation of Node.js by typing:
If the command returns a version, Node.js is properly working. Next, you will need to install npm
. Run the following:
To check your installation run:
If the command returns a version, npm
is properly installed, and you are ready to move on.
Building the Loop
Manual Builds
Navigate to your Loop directory within the open prompt:
In order for your Loop to work correctly, you now need to install its dependencies:
Let the installer finish -- this may take several minutes. Next, you will need to build your project:
This command will be used often -- to save time, push the up arrow while in your prompt to see and use previous commands.
This will create a loop.js file in the dist folder of your project. This is the main file needed to use your Loop locally.
Every time your code changes, you will need to rebuild your Loop. You will then need to restart it from the Loop Library.
Automatic Builds
It might be beneficial or easier if your loop.js file were automatically built any time you save changes to your Loop's code. The main situation for this is to be used in tandem with Live Reloading.
Our suggested option for building the loop.js file automatically is to use a specific Webpack "watch" command. An alternative, which we won't dive into, is using Nodemon.
In order to do this, you need to add a new item to the "scripts"
section in your Loop's package.json
. An example of what the new script could look like is this:
Moving forward, you could run the following command (rather than npm run build
):
At this point, any time you save a file in your Loop project, Webpack will automatically detect it and rebuild the loop.js file.
Last updated