Auto Compile React Theme

To automate the compilation of your React theme on cPanel or Siteworx, you need to create a script that will run the build process. 

Step 1: Create the Auto Compile Script

  1. Access the File Manager
    • Log in to your cPanel or Siteworx account.
    • Navigate to the "File Manager" from the dashboard.
  2. Create a New Script File
    • In the directory where you want to manage your React theme (usually public_html or a subdirectory), create a new file. You can name it
  3. Edit the Script File
    • Open the newly created file for editing.
    • Add the following script to compile your React theme:
# Navigate to the project directory
cd /home/yourusername/public_html/yourproject
# Pull the latest changes from the repository (if using version control)
git pull origin main
# Install dependencies
npm install
# Run the build script
npm run build
    • Replace /home/yourusername/public_html/yourproject with the actual path to your React project.
    • If you're not using a version control system like Git, you can omit the git pull line.
  1. Save and Close the File
  2. Set File Permissions
    • Ensure the script is executable. You can do this via the File Manager or by using an SSH terminal:
chmod +x /home/yourusername/public_html/yourproject/

Step 2: Running the Script Manually

  1. Access the Terminal
    • If your hosting provides SSH access, log in via SSH.
    • Navigate to the directory where the script is located:
cd /home/yourusername/public_html/yourproject
  1. Execute the Script
    • Run the script manually:
    • This will compile your React theme based on the latest code.

Step 3: Setting Up a Cron Job

To automate the process of compiling your React theme at regular intervals or after specific events, you can set up a cron job.

  1. Access the Cron Jobs Section
    • In your cPanel or Siteworx dashboard, locate and click on the "Cron Jobs" icon.
  2. Create a New Cron Job
    • In the Cron Jobs interface, you will see a form to add a new cron job.
    • Set the schedule for your cron job using the provided fields (Minute, Hour, Day, Month, and Weekday). For example, to run the job every hour, you can set:
Minute: 0
Hour: *
Day: *
Month: *
Weekday: *
  1. Enter the Command to Run
    • In the "Command" field, enter the path to your script:
    • Replace /home/yourusername/public_html/yourproject/ with the actual path to your script.
  1. Save the Cron Job
    • Click "Add New Cron Job" to save it. The cron job will now run automatically at the specified intervals, compiling your React theme.

Testing and Verification

  1. Manual Execution
    • Manually run the script as described in Step 2 to ensure it works correctly.
  2. Cron Job Verification
    • Wait for the next scheduled run of your cron job or manually trigger it via your cPanel/Siteworx interface to ensure it compiles the React theme as expected.

Automating the process of compiling your React theme on cPanel or Siteworx ensures your site is always up-to-date with the latest changes.

Need a Helping Hand with Your Project?

Whether you need continuous support through our Flexible Retainer Plans or a custom quote, we're dedicated to delivering services that align perfectly with your business goals.

Please enter your name

Please enter your email address

Contact by email or phone?

Please enter your company name.

Please enter your phone number

What is your deadline?

Please tell us a little about your project