/lovable-issues

Exporting Lovable Projects for Manual Deployment

Learn why exporting Lovable projects for manual hosting needs adjustments, plus export steps and best practices for seamless success.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

Why Exporting for Manual Hosting Requires Adjustments in Lovable

 
Understanding the Export Process and Its Unique Demands
 

When a project like Lovable is created, it is usually designed to run in a specific environment. Exporting the project for manual hosting means taking a version of the software that was made to work automatically within a certain system and preparing it to be run on your own server. This process brings several hidden challenges. The project settings, file paths, environment variables, and server configurations that worked in the original setup may not be set up automatically when you host the project manually.

  • The original environment might have taken care of many configuration details in the background. When you move away from that environment, you must adjust these settings yourself.
  • Manual hosting requires explicit instructions for the server to know where to find the files, how to handle file permissions, and how to route data. This is very different from an environment where these tasks were pre-configured.
  • Many settings are usually bundled together in the export file and might need careful tweaking to match your actual server paths, security settings, or performance requirements.

// Example of configuration settings that were automatically managed:
// In the original environment, these values were set dynamically.
{
    "server\_mode": "auto",
    "static_files_path": "/preconfigured/path",
    "env\_variables": {
        "DEBUG": false,
        "API\_KEY": "auto-generated-key"
    }
}

 
Reasons Behind the Need for Adjustments
 

The adjustments are needed because of the differences between an automated deployment system and a manually hosted server. When you export for manual hosting, the project no longer has the built-in environment that arranged everything for you. This means you must do some of the work that the original system did in the background.

  • The project might reference resources with paths that worked only in the original environment. When you host it manually, those paths may not match the structure of your server.
  • Security and access settings that were automatically applied must now be set manually. This ensures that your manually hosted project is properly secured.
  • Tools and scripts that handled tasks like file permissions, routing, and plugin integrations in the full automated setup now need manual intervention. Without these adjustments, some features may not work as expected.

// Sample snippet representing manual adjustments needed.
// This does not show a fix, only reflects a change in context.
{
    "server\_mode": "manual",
    "static_files_path": "/your/custom/path",
    "env\_variables": {
        "DEBUG": true,
        "API\_KEY": "your-custom-key"
    }
}

How to Export a Lovable Project for Manual Hosting

 
Exporting Your Lovable Project Files
 

  • When you finish your work in Lovable, click on the export option (if available) to download your project files. You should receive a ZIP file containing your HTML, CSS, and JavaScript files.
  • Extract the ZIP file on your computer. You will see files like index.html, style.css, and others that make up your project.

 
Organizing Your Files for Manual Hosting
 

  • Create a new folder on your computer called lovable-host.
  • Place all the exported files into the lovable-host folder. If your project already has separate folders (for example, a css folder and a js folder), keep that structure intact.

 
Updating Your Entry Point File
 

  • Open the index.html file in a plain text editor (such as Notepad on Windows or TextEdit on Mac).
  • This file is the starting point for your hosted site, so you need to ensure that it correctly references all your style and script files using relative paths. For example, if your CSS is in a folder named css, confirm the link looks like this:

<link rel="stylesheet" href="css/style.css">
  • If you have JavaScript files stored in a folder named js, add or verify a similar reference before the closing </body> tag:

<script src="js/app.js"></script>

 
Adding External Dependency References
 

  • Lovable projects sometimes require external libraries. Since Lovable does not have a terminal, you must load these dependencies directly from a Content Delivery Network (CDN) by inserting the proper links into your index.html.
  • For instance, if you need jQuery, paste the following snippet before the closing </body> tag:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  • Or, if you want to include Bootstrap (which comes with both CSS and JavaScript) to style your project, add these lines in the <head> section for the CSS:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  • And before the closing </body> tag for the Bootstrap JavaScript and its dependency:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

 
Setting Up a Basic Server (Optional)
 

  • If your hosting environment requires a server (for example, to handle dynamic routing), create a new file in the lovable-host folder called server.js.
  • Paste the following code into server.js. This code uses Express to serve your static files:

const express = require('express');
const app = express();
const port = process.env.PORT || 3000;

// Serves all files from the current directory
app.use(express.static(\_\_dirname + '/'));

// Starts the server
app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});
  • Because Lovable doesn’t support terminal commands, you cannot run npm install express here. Instead, if your hosting provider supports Node.js, they may already include Express or allow you to add a package.json file. Create a file named package.json in the same folder and add the following content:

{
  "name": "lovable-project",
  "version": "1.0.0",
  "dependencies": {
    "express": "^4.17.1"
  },
  "scripts": {
    "start": "node server.js"
  }
}
  • If your host does not support Node.js for manual dependency installation, you can skip the server setup and rely solely on static hosting.

 
Uploading Your Project to Your Hosting Provider
 

  • After making all necessary changes, upload the entire contents of the lovable-host folder to your hosting provider using their file manager or FTP tool.
  • Ensure that your index.html file is in the root directory of the host so that it loads by default when someone visits your site.
  • Use your hosting provider’s URL to test that your project works correctly online.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Best Practices for Exporting and Hosting Lovable Projects

 
Project Structure and Configuration
 

  • Create a new project file called lovable.config.json in your project’s root. This file tells Lovable how to package and export your project.
  • Add the following JSON content to define your project settings and dependencies. Paste this into lovable.config.json:
    
    {
      "projectName": "MyLovableProject",
      "version": "1.0.0",
      "main": "index.html",
      "dependencies": {
        "someLibrary": "1.2.3",
        "anotherLibrary": "4.5.6"
      },
      "export": {
        "include": ["index.html", "styles.css", "app.js"],
        "exclude": ["\*.log", "temp/"]
      }
    }
    
  • This file serves as your guide for which files to include when exporting your project and lists the libraries your project needs.

 
Embedding Dependency Installation Code
 

  • Since Lovable does not have a terminal, you need to add code that automatically checks for and installs dependencies when your project is first loaded.
  • Create a new JavaScript file called setupDependencies.js in your project’s root directory. Insert the following code:
    
    (function() {
      // Check if dependencies are already loaded in the browser’s storage/local file.
      if (!localStorage.getItem('dependenciesInstalled')) {
        // Simulate installation process by dynamically loading required libraries.
        var libs = {
          "someLibrary": "https://example.com/someLibrary-1.2.3.js",
          "anotherLibrary": "https://example.com/anotherLibrary-4.5.6.js"
        };
        
        for (var lib in libs) {
          var script = document.createElement('script');
          script.src = libs[lib];
          document.head.appendChild(script);
        }
        
        localStorage.setItem('dependenciesInstalled', 'true');
      }
    })();
    
  • This script should be loaded early in your HTML file so that all libraries are available. Add the following tag inside the <head> of your index.html file:
    
    <script src="setupDependencies.js"></script>
    

 
Exporting Your Lovable Project
 

  • Design a dedicated export function to package your project files. Create a new file called exportProject.js in your project’s root.
  • Paste the following code snippet in exportProject.js. This function will gather all necessary files as defined in lovable.config.json and prepare a downloadable package:
    
    function exportProject() {
      // Fetch the configuration details
      fetch('lovable.config.json')
        .then(response => response.json())
        .then(config => {
          // In a real environment, package the files listed under config.export.include
          // Here we simulate export by alerting the user
          alert("Exporting " + config.projectName + " v" + config.version + " with files: " + config.export.include.join(", "));
          
          // Additional logic to zip and download files would be implemented here.
        })
        .catch(err => {
          console.error("Error reading configuration:", err);
        });
    }
    
    // Hook the export function to a button click
    document.getElementById('exportButton').addEventListener('click', exportProject);
    
  • To allow users to trigger this export, add an export button in your index.html body:
    
    <button id="exportButton">Export Project</button>
    

 
Hosting Best Practices
 

  • For hosting your project, ensure that your project files are cleanly organized, and sensitive configuration files like logs or temporary files are excluded using the exclude rule in lovable.config.json.
  • Ensure your main file (index.html) references all external scripts correctly. For example, at the bottom of the index.html file, insert the following:
    
    <!-- Place main application logic after dependencies have loaded -->
    <script src="app.js"></script>
    
  • If you need to configure environment-specific settings (like API endpoints), create a file called config.js and include settings like this:
    
    var AppConfig = {
      apiEndpoint: "https://api.myproject.com",
      debugMode: false
    };
    
  • Make sure config.js is loaded before your main application code in index.html:
    
    <script src="config.js"></script>
    
  • For troubleshooting errors on the hosting side, always check that external scripts load correctly. Use browser developer tools (like the console) to see any failed network requests or missing files.

 
Final Integration and Testing
 

  • Ensure that all these new files (lovable.config.json, setupDependencies.js, exportProject.js, and config.js) are saved in your project’s root directory.
  • Test your project by loading index.html in your browser. The dependency installer should run automatically and you should be able to use the export button to simulate a project export.
  • If any errors appear, review the code snippets to confirm file paths, file names, and referenced URLs. Check that the lovable.config.json file is correctly formatted as valid JSON.

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022