Installation
Creating a new project
We recommend using create-leafjs-app
(or cla
for short) for newly created projects. CLA will automatically handle the development server and build process by interacting with Rollup JavaScript API.
However, using other bundlers such as Webpack may be possible - but with no offical support.
Simply run:
- Yarn
- NPX
yarn create leafjs-app my-app
npx create-leafjs-app my-app
To create a new app named my-app
. Then cd my-app
to go into the app directory and install the dependencies using either Yarn or NPM. Finally, run:
- Yarn
- NPM
yarn dev
npm run dev
To start a hot reloading development server.
Other commands such as build
, start
are also available.
Adding Leaf to an existing project
To manually add Leafjs to an existing project, install the required packages:
- Yarn
- NPM
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:
{
"scripts": {
"build": "leaf build",
"dev": "leaf dev",
"start": "leaf start"
}
}
Where 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!