Learn why exporting Lovable projects for manual hosting needs adjustments, plus export steps and best practices for seamless success.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
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.
// 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.
// 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"
}
}
Exporting Your Lovable Project Files
index.html
, style.css
, and others that make up your project.
Organizing Your Files for Manual Hosting
lovable-host
.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
index.html
file in a plain text editor (such as Notepad on Windows or TextEdit on Mac).css
, confirm the link looks like this:
<link rel="stylesheet" href="css/style.css">
js
, add or verify a similar reference before the closing </body>
tag:
<script src="js/app.js"></script>
Adding External Dependency References
index.html
.</body>
tag:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<head>
section for the CSS:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
</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)
lovable-host
folder called server.js
.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}`);
});
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"
}
}
Uploading Your Project to Your Hosting Provider
lovable-host
folder to your hosting provider using their file manager or FTP tool.index.html
file is in the root directory of the host so that it loads by default when someone visits your site.
Project Structure and Configuration
lovable.config.json
in your project’s root. This file tells Lovable how to package and export your project.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/"]
}
}
Embedding Dependency Installation Code
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');
}
})();
<head>
of your index.html
file:
<script src="setupDependencies.js"></script>
Exporting Your Lovable Project
exportProject.js
in your project’s root.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);
index.html
body:
<button id="exportButton">Export Project</button>
Hosting Best Practices
exclude
rule in lovable.config.json
.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>
config.js
and include settings like this:
var AppConfig = {
apiEndpoint: "https://api.myproject.com",
debugMode: false
};
config.js
is loaded before your main application code in index.html
:
<script src="config.js"></script>
Final Integration and Testing
lovable.config.json
, setupDependencies.js
, exportProject.js
, and config.js
) are saved in your project’s root directory.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.lovable.config.json
file is correctly formatted as valid JSON.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.