Creating a new project
We recommend using
However, using other bundlers such as Webpack may be possible - but with no offical support.
yarn create leafjs-app my-app
npx create-leafjs-app my-app
To create a new app named
cd my-app to go into the app directory and install the dependencies using either Yarn or NPM. Finally, run:
npm run dev
To start a hot reloading development server.
Other commands such as
start are also available.
Adding Leaf to an existing project
To manually add Leafjs to an existing project, install the required packages:
yarn add @leaf-web/core @leaf-web/parser
npm i @leaf-web/core @leaf-web/parser
Then in your
package.json, add the following scripts:
"build": "leaf build",
"dev": "leaf dev",
"start": "leaf start"
build is used to build production-ready bundles and
dev to start a hot-reloading development server. The
start command is to serve the bundle produced by
build. However, the
start command should only be used for testing purposes - it contains no optimization!