Skip to content

Commit

Permalink
fixed standalone build
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodacus committed Jan 5, 2025
1 parent aab2adc commit c11afdf
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 52 deletions.
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,35 @@ bolt.diy was originally started by [Cole Medin](https://www.youtube.com/@ColeMed

## Setup

If you're new to installing software from GitHub, don't worry! If you encounter any issues, feel free to submit an "issue" using the provided links or improve this documentation by forking the repository, editing the instructions, and submitting a pull request. The following instruction will help you get the stable branch up and running on your local machine in no time.
## Running the Application

Let's get you up and running with the stable version of Bolt.DIY!
You have three options for running Bolt.DIY: using npm (recommended), direct installation, or using Docker.

## Quick Download
### Option 1: CLI Installation (Recommended)
The easiest way to get started with bolt.diy is using npm:

[![Download Latest Release](https://img.shields.io/github/v/release/stackblitz-labs/bolt.diy?label=Download%20Bolt&sort=semver)](https://github.com/stackblitz-labs/bolt.diy/releases/latest) ← Click here to go the the latest release version!
```bash
# Install globally using npm
npm install -g bolt-diy

- Next **click source.zip**
# Start bolt
bolt.diy
```

Available commands:
```bash
bolt.diy # Start with default settings (port 5173)
bolt.diy --port 3000 # Start on custom port
bolt.diy --help # Show help message
bolt.diy --version # Show version info
```

The CLI will automatically handle all dependencies and setup, making it the simplest way to get started.

### Option 2: Direct Installation
If you prefer to run from source or contribute to development:

## Prerequisites
### Prerequisites

Before you begin, you'll need to install two important pieces of software:

Expand All @@ -126,30 +141,26 @@ Node.js is required to run the application.
```
3. Look for `/usr/local/bin` in the output

## Running the Application

You have two options for running Bolt.DIY: directly on your machine or using Docker.

### Option 1: Direct Installation (Recommended for Beginners)

1. **Install Package Manager (pnpm)**:
5. **Install Package Manager (pnpm)**:
```bash
npm install -g pnpm
```

2. **Install Project Dependencies**:
6. **Install Project Dependencies**:
```bash
pnpm install
```

3. **Start the Application**:
7. **Start the Application**:
```bash
pnpm run dev
```

**Important Note**: If you're using Google Chrome, you'll need Chrome Canary for local development. [Download it here](https://www.google.com/chrome/canary/)

### Option 2: Using Docker
### Option 3: Using Docker

This option requires some familiarity with Docker but provides a more isolated environment.

Expand All @@ -173,8 +184,6 @@ This option requires some familiarity with Docker but provides a more isolated e
```




## Configuring API Keys and Providers

### Adding Your API Keys
Expand Down
4 changes: 4 additions & 0 deletions app/lib/modules/llm/providers/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export default class OllamaProvider extends BaseProvider {
// Backend: Check if we're running in Docker
const isDocker = process.env.RUNNING_IN_DOCKER === 'true';

if (!baseUrl) {
throw new Error('No baseUrl found for OLLAMA provider');
}

baseUrl = isDocker ? baseUrl.replace('localhost', 'host.docker.internal') : baseUrl;
baseUrl = isDocker ? baseUrl.replace('127.0.0.1', 'host.docker.internal') : baseUrl;

Expand Down
8 changes: 4 additions & 4 deletions bin/bolt.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ Options:
-p, --port Specify a custom port (default: 5173)
Examples:
bolt Start with default settings
bolt --port 3000 Start on port 3000
bolt --help Show this help message
bolt --version Show version information
bolt.diy Start with default settings
bolt.diy --port 3000 Start on port 3000
bolt.diy --help Show this help message
bolt.diy --version Show version information
For more information, visit: https://github.com/stackblitz-labs/bolt.diy
`);
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bolt.diy",
"description": "An AI Agent",
"name": "@stackblitz-labs/bolt.diy",
"description": "Welcome to bolt.diy, An open source tool that lets you use multiple AI language models in one place. Supports OpenAI, Anthropic, Gemini, Mistral, and others, with easy integration for additional models via the Vercel AI SDK.",
"private": false,
"license": "MIT",
"sideEffects": false,
Expand All @@ -24,7 +24,8 @@
"peerDependencies": {
"wrangler": "^3.91.0",
"@remix-run/cloudflare": "^2.15.0",
"@remix-run/cloudflare-pages": "^2.15.0"
"@remix-run/cloudflare-pages": "^2.15.0",
"vite-plugin-node-polyfills": "^0.22.0"
},
"scripts": {
"deploy": "npm run build && wrangler pages deploy",
Expand Down
53 changes: 24 additions & 29 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { defineConfig, type ViteDevServer } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules';
import tsconfigPaths from 'vite-tsconfig-paths';
import fs from 'fs';

import { execSync } from 'child_process';

Expand All @@ -18,21 +19,20 @@ const getGitHash = () => {


export default defineConfig((config) => {
const isServer = process.env.NODE_ENV === 'production' && process.env.BUILDING_SERVER === 'true';
const isServer = process.env.NODE_ENV === 'production'&& process.env.BUILDING_SERVER === 'true';

return {
define: {
__COMMIT_HASH: JSON.stringify(getGitHash()),
__APP_VERSION: JSON.stringify(process.env.npm_package_version),
'process.env': JSON.stringify(process.env),
'global': 'globalThis',
},
build: {
target: 'esnext',
rollupOptions: {
// Mark problematic modules as external for server build
external: isServer ? [
'vite-plugin-node-polyfills/shims/process',
'buffer',
'path'
] : [],
external: isServer ? ['buffer', 'path'] : [],
output: {
// Ensure correct format for server build
format: 'esm',
Expand All @@ -42,14 +42,26 @@ export default defineConfig((config) => {
plugins: [
nodePolyfills({
include: ['path', 'buffer'],
// globals: {
// Buffer: true,
// global: true,
// process: true,
// },
globals: {
Buffer: true,
global: true,
process: true,
},
// Ensure polyfills are inlined during build
protocolImports: true,
}),
// {
// name: 'inject-process-shim',
// transform(code, id) {
// // Inject process shim only for server build entry point
// if (isServer && id.includes('entry.server')) {
// return {
// code: processShim + '\n' + code,
// map: null
// };
// }
// },
// },
config.mode !== 'test' && remixCloudflareDevProxy(),
remixVitePlugin({
future: {
Expand All @@ -62,25 +74,8 @@ export default defineConfig((config) => {
UnoCSS(),
tsconfigPaths(),
chrome129IssuePlugin(),

config.mode === 'production' && optimizeCssModules({ apply: 'build' }),
// Add polyfill injection plugin
// {
// name: 'inject-polyfills',
// transform(code, id) {
// // Only inject in client builds
// if (!isServer && id.includes('entry.client')) {
// const injection = `
// import { Buffer } from 'buffer';
// window.Buffer = Buffer;
// `;
// return {
// code: injection + code,
// map: null
// };
// }
// }
// },

],

envPrefix: ["VITE_","OPENAI_LIKE_API_BASE_URL", "OLLAMA_API_BASE_URL", "LMSTUDIO_API_BASE_URL","TOGETHER_API_BASE_URL"],
Expand Down

0 comments on commit c11afdf

Please sign in to comment.