CHAPTER 06 / WEBFRONT
Embed and distribute
Turn sources into an embedded interface.
Generate the C++ resources
In the application terminal, this command compiles TSX and packages assets and dependency notices into a compressed header. C++ recompilation remains explicit.
wf embed ui/main.tsx --output generated/LifeUI.hppChange the entry point
The embedded programme replaces the development project and bootstrap with the generated provider. This code uses the Life example’s headers and assumes generated/LifeUI.hpp is on the include path. The repository already provides the equivalent WebFrontLifeEmbedded target.
#include "Life.hpp"
#include "LifeFrontend.hpp"
#include <webfront/WebFront.hpp>
#include "generated/LifeUI.hpp"
int main() {
webfront::demo::LifeAppWithAssets<webfront::fs::LifeUI> app;
app.cppFunction("life.step", &webfront::demo::nextLife);
app.show();
}Rebuild the example
Close the developer window and run these commands in the same build directory. With Visual Studio, run examples\Debug\WebFrontLifeEmbedded.exe. The application runs offline without UI sources or the tool cache. You still need to handle native-engine deployment: wf embed is not an installer generator.
cmake .. -DWEBFRONT_LIFE_ASSETS="$PWD/life-project/generated/LifeUI.hpp"
cmake --build . --target WebFrontLifeEmbedded
examples/WebFrontLifeEmbeddedQuestion