You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -20,59 +20,169 @@ Uploading a map using [GitHub Pages](https://docs.github.com/pages) will host yo
20
20
21
21
Uploading a map using the [WA map storage](https://docs.workadventu.re/map-building/tiled-editor/publish/wa-hosted) will host your project on WA servers. It's a bit more difficult to set up, but it comes with great advantages, like being able to have private repositories.
22
22
23
-
## 🗂️ Structure
23
+
## 🗂️ Project Structure
24
24
25
-
We recommend following this file structure:
25
+
```
26
+
map-starter-kit/
27
+
├── 📁 app/ # Server entry point (loads @workadventure/map-starter-kit-core)
28
+
│ └── app.ts # Re-exports the Express app from the core package
The **server** (Express app, controllers, HTML publishing pages, static assets) is provided by the npm package **`@workadventure/map-starter-kit-core`**. Updating this dependency gives you new publishing UI and server features without changing your maps or config.
26
42
27
-
-*`public/`*: Static files like PDFs or audio files
28
-
-*`src/`*: Script files or design source files
43
+
### Quick Reference
44
+
45
+
-*`src/`*: **Map scripts** (MUST be here for compilation) ⚠️
29
46
-*`tilesets/`*: All PNG tilesets
47
+
-*`app/`*: **Server entry point** – loads the core package; do not add server logic here
30
48
31
49
> [!TIP]
32
50
> - If you want to use more than one map file, just add the new map file in the root folder (we recommend creating a copy of *office.tmj* and editing it to avoid any mistakes).
33
51
> - We recommend using **512x512** images for the map thumbnails.
34
-
> - If you are going to create custom websites to embed in the map, please reference the HTML files in the `input` option in *vite.config.js*.
52
+
> - If you are going to create custom websites to embed in the map, please reference the HTML files in the `input` option in *buildmap.vite.config.js*.
53
+
54
+
### 📁 Server entry point (`app/`)
55
+
56
+
The `app/` directory contains only the **entry point** that loads the server from **`@workadventure/map-starter-kit-core`**.
57
+
58
+
-*`app.ts`*: Imports and re-exports the Express app from the core package (for Vite’s server plugin).
59
+
60
+
The actual server (Express, routes, HTML pages, upload, map storage) lives in the dependency. To get updates to the publishing UI and server behaviour, run `npm update @workadventure/map-starter-kit-core`.
61
+
62
+
> [!IMPORTANT]
63
+
> Do **not** add server logic or new controllers in `app/`. The server is fully provided by the core package.
64
+
65
+
### 📁 Map Scripts Development (`src/`) ⚠️
66
+
67
+
The `src/` directory is where you **MUST** place **all map-related scripts** that will be executed in the browser. See [src/README.md](./src/README.md) for detailed documentation and examples.
68
+
69
+
-*`main.ts`*: Main map script (referenced in `.tmj` files)
70
+
71
+
> [!IMPORTANT]
72
+
> **All map scripts MUST be placed in the `src/` directory** to be properly compiled and bundled by Vite. Scripts in this directory are:
73
+
> - Automatically transformed from TypeScript to JavaScript
74
+
> - Bundled with their npm dependencies (like `@workadventure/scripting-api-extra`)
75
+
> - Served with the correct MIME types
76
+
> - Referenced in your `.tmj` map files using paths like `src/main.ts`
77
+
78
+
> [!WARNING]
79
+
> Do not place map scripts outside the `src/` directory. They will not be compiled correctly and will cause errors in the browser.
35
80
36
81
## 📜 Requirements
37
82
38
83
- Node.js version >= 18
39
84
40
-
## Installation and testing
41
-
42
85
## 🛠️ Installation and Testing
43
86
44
-
With npm installed (which comes with [Node.js](https://nodejs.org/en/)), run the following command in the root directory of the project:
87
+
### Prerequisites
88
+
89
+
-**Node.js** version >= 18 ([Download Node.js](https://nodejs.org/en/))
90
+
-**npm** (comes with Node.js)
91
+
92
+
### 📦 Installation
93
+
94
+
1. Clone or download this repository
95
+
2. Navigate to the project root directory
96
+
3. Install dependencies:
45
97
46
98
```bash
47
99
npm install
48
100
```
49
101
50
-
Then, you can test your map by running:
102
+
This will install all required dependencies, including Vite, TypeScript, WorkAdventure packages, and **`@workadventure/map-starter-kit-core`** (server and publishing UI).
103
+
104
+
### 🚀 Development
105
+
106
+
#### Start Development Server
107
+
108
+
Start the Vite development server with hot module replacement:
51
109
52
110
```bash
53
111
npm run dev
54
112
```
55
113
56
-
You can also test the optimized map as it will be in production by running:
114
+
This will:
115
+
- Start the Vite dev server (usually on `http://localhost:5173`)
116
+
- Enable hot module replacement for instant updates
117
+
- Automatically transform TypeScript files in `src/`
118
+
- Serve your maps and assets
119
+
120
+
> [!TIP]
121
+
> The development server will automatically open your browser. If not, navigate to the URL shown in the terminal.
122
+
123
+
#### Test Production Build
124
+
125
+
To test how your map will behave in production:
57
126
58
127
```bash
59
-
npm run build
60
-
npm run prod
128
+
# Build the optimized production version for your map
129
+
npm run buildmap
130
+
61
131
```
62
132
63
-
You can manually [upload your map to the WA Map Storage]([WA Map Storage](https://github.com/workadventure/upload-maps)) by running:
133
+
This will:
134
+
- Compile TypeScript to JavaScript
135
+
- Optimize and bundle all assets
136
+
- Create a production-ready `dist/` folder
137
+
- Start a preview server to test the optimized build
138
+
139
+
### 📤 Upload Your Map
140
+
141
+
#### Upload to WA Map Storage
142
+
143
+
To upload your map to the WorkAdventure Map Storage:
64
144
65
145
```bash
66
146
npm run upload
67
147
```
68
148
69
-
The three important variables that control the upload feature are:
149
+
This command will:
150
+
1. Build your map (`npm run buildmap`)
151
+
2. Upload it to the configured WA Map Storage
152
+
153
+
> [!IMPORTANT]
154
+
> Before uploading, you need to configure your upload settings. The upload feature requires three environment variables:
155
+
156
+
1.**`MAP_STORAGE_URL`** - Your WorkAdventure Map Storage URL
157
+
-*Local development*: Created in `.env` by the upload command
158
+
-*CI/CD*: Add as a GitHub secret (optional)
159
+
160
+
2.**`MAP_STORAGE_API_KEY`** - Your API key for authentication
161
+
-*Local development*: Created in `.env.secret` by the upload command
162
+
-*CI/CD*: Add as a GitHub secret (required)
163
+
164
+
3.**`UPLOAD_DIRECTORY`** - Directory path on the storage server
165
+
-*Local development*: Created in `.env` by the upload command
166
+
-*CI/CD*: Add as a GitHub secret (optional)
167
+
168
+
#### Configure Upload Settings
169
+
170
+
You can configure these settings through the web interface:
171
+
1. Start the development server (`npm run dev`)
172
+
2. Navigate to the upload configuration page
173
+
3. Fill in your Map Storage credentials
174
+
4. Save and upload your map
175
+
176
+
For more details, read [the WorkAdventure upload documentation](https://docs.workadventu.re/map-building/tiled-editor/publish/wa-hosted).
70
177
71
-
1.`MAP_STORAGE_URL`*(local: created in .env by the upload command / CI: to be added as a Github secret optionally)*
72
-
2.`MAP_STORAGE_API_KEY`*(local: created in .env.secret by the upload command / CI: to be added as a Github secret)*
73
-
3.`UPLOAD_DIRECTORY`*(local: created in .env by the upload command / CI: to be added as a Github secret optionally)*
178
+
### 📋 Available Scripts
74
179
75
-
Read [the documentation](https://docs.workadventu.re/map-building/tiled-editor/publish/wa-hosted) to learn more about the upload feature.
180
+
| Command | Description |
181
+
|---------|-------------|
182
+
|`npm run dev`| Start Vite development server with hot reload |
183
+
|`npm run buildmap`| Build only the map files (without frontend) |
184
+
|`npm run upload`| Build and upload map to WA Map Storage |
185
+
|`npm run upload-only`| Upload map without rebuilding (requires existing build) |
0 commit comments