Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Compilation pour le Web¶
Voir aussi
Cette page décrit comment compiler les binaires de l'éditeur HTML5 et les modèles d'exportation à partir du code source. Si vous souhaitez plutôt exporter votre projet vers HTML5, lisez Exportation pour le Web.
Pré-requis¶
Pour compiler des modèles d'exportation pour le Web, ce qui suit est nécessaire :
SCons 3.0+ build system.
Voir aussi
Pour récupérer le code source de Godot pour le compiler, voir Obtenir la source.
Pour un aperçu général de l'utilisation de SCons pour Godot, voir Introduction au buildsystem.
Création de modèles d'exportation¶
Avant de commencer, confirmez que emcc
est disponible dans votre PATH. Ceci est généralement configuré par le SDK Emscripten, par exemple lors de l'invocation de emsdk activate
et source ./emsdk_env.sh
/emsdk_env.bat
.
Open a terminal and navigate to the root directory of the engine source code.
Then instruct SCons to build the Web platform. Specify target
as
either template_release
for a release build or template_debug
for a debug build:
scons platform=web target=template_release
scons platform=web target=template_debug
Par défaut, le singleton JavaScript sera compiler dans le moteur.. Les modèles d'exportation officiels ont également le JavaScript singleton activé. Comme les appels eval()
peuvent être un problème de sécurité, l'option javascript_eval
peut être utilisée pour compiler sans le singleton :
scons platform=web target=template_release javascript_eval=no
scons platform=web target=template_debug javascript_eval=no
The engine will now be compiled to WebAssembly by Emscripten. Once finished,
the resulting file will be placed in the bin
subdirectory. Its name is
godot.web.opt.wasm32.zip
for release or godot.web.opt.debug.wasm32.zip
for debug.
Finally, rename the zip archive to web_release.zip
for the
release template:
mv bin/godot.web.opt.wasm32.zip bin/web_release.zip
And web_debug.zip
for the debug template:
mv bin/godot.web.opt.debug.wasm32.zip bin/web_debug.zip
GDExtension¶
The default export templates do not include GDExtension support for performance and compatibility reasons. See the export page for more info.
You can build the export templates using the option dlink_enabled=yes
to enable GDExtension support:
scons platform=web dlink_enabled=yes target=template_release
scons platform=web dlink_enabled=yes target=template_debug
Once finished, the resulting file will be placed in the bin
subdirectory.
Its name will have _dlink
added.
Finally, rename the zip archives to web_dlink_release.zip
and
web_dlink_release.zip
for the release template:
mv bin/godot.web.opt.wasm32.dlink.zip bin/web_dlink_release.zip
mv bin/godot.web.opt.debug.wasm32.dlink.zip bin/web_dlink_debug.zip
Building the editor¶
It is also possible to build a version of the Godot editor that can run in the browser. The editor version is not recommended over the native build. You can build the editor with:
scons platform=web target=editor
Once finished, the resulting file will be placed in the bin
subdirectory.
Its name will be godot.web.opt.tools.wasm32.zip
. You can upload the
zip content to your web server and visit it with your browser to use the editor.
Reportez-vous à la page exportation pour connaître la configuration requise du serveur Web.
Astuce
The Godot repository includes a Python script to host a local web server. This can be used to test the web editor locally.
After compiling the editor, extract the ZIP archive that was created in the
bin/
folder, then run the following command in the Godot repository
root:
# You may need to replace `python` with `python3` on some platforms.
python platform/web/serve.py
This will serve the contents of the bin/
folder and open the default web
browser automatically. In the page that opens, access godot.tools.html
and you should be able to test the web editor this way.
Note that for production use cases, this Python-based web server should not be used. Instead, you should use an established web server such as Apache or nginx.