Download
Using Babylon.js Editor CLI
Introduction
The Babylon.js Editor provides a package named babylonjs-editor-cli that can be installed as a dependency of a project. This package provides a command line interface (CLI) to generate all necessary assets and files in the public/scene folder without having to open the editor application.
In other words, it allows you to generate all necessary assets in your own CI/CD pipeline.
The package is available on NPM here.
The goal of this CLI is to:
  • generate all .babylon scenes.
  • generate all necessary assets including down-scaled and compressed textures.
  • collect all scripts attached to entities in order to bundle them properly.
Installing babylonjs-editor-cli
Starting from Babylon.js Editor v5.3.0, the babylonjs-editor-cli package is included as a dependency of newly generated projects. Therefore, if you have created your project with a previous version of the editor, you will need to install it manually:
bash
Then, in your package.json, you can add a script to easily run the CLI:
bash
Packing project
The babylonjs-editor-cli package provides a command named pack that will generate all necessary assets and files in the public/scene folder of your project.
To run the command, simply use:
bash
A cache is automatically saved locally in order to speed up the packing process on subsequent runs.
The pack command will also collect all scripts attached to entities in order to bundle them properly.
It is IMPORTANT to pack the project before building it so that all scripts (located at src/scripts.ts) are properly bundled.
Here is a simple example on how the CI/CD pipeline could look like:
bash