Accelerate HTML5 Project Setup with ELF CLI: Fast Scaffolding and Build Automation

ELF is a Node‑based CLI tool that streamlines HTML5 scene‑marketing project creation by providing quick installation, project initialization with ready‑made templates, and automated build processes powered by webpack, helping developers avoid repetitive setup tasks.

Aotu Lab
Aotu Lab
Aotu Lab
Accelerate HTML5 Project Setup with ELF CLI: Fast Scaffolding and Build Automation

ELF (short for "Elf") is a Node.js CLI designed to simplify the creation and build workflow of HTML5 scene‑marketing projects, offering project scaffolding, template selection, and automated build features.

Quick Start

Installation ELF requires Node >= 4 and can be installed globally via npm. Because of network issues with node-sass and phantomjs , it is recommended to use the Taobao mirrors:

# mac/linux
SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs/ npm install -g elf-cli --registry=https://registry.npm.taobao.org
# windows
npm install -g elf-cli --registry=https://registry.npm.taobao.org --SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ --PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs/

After installation, run elf --help to view available commands.

Project Initialization To start a full‑page vertical‑swipe HTML5 project, use the swiper template:

# Initialize project with swiper template
elf init -t swiper demo-swiper

# Enter directory and install dependencies
cd demo-swiper && npm install

# Start development server (hot reload, automatic style compilation)
elf start

The project runs in development mode with style hot‑loading and other conveniences.

Deployment When development is finished, build the project for production: elf build This generates a dist folder ready for deployment.

The workflow eliminates repetitive initialization and build steps and has been adopted in over ten JD brand H5 projects.

Feature Overview

ELF consists of three main parts: project build, example templates, and common components.

Project Build

ELF is built on webpack and bundles a suite of loaders and plugins, including:

webpack‑dev‑server

sass‑loader, less‑loader, style‑loader

html‑webpack‑plugin

postcss‑loader, autoprefixer, postcss‑plugin‑px2rem, postcss‑sprites, postcss‑assets

image‑webpack‑loader

Various *‑loader utilities

Key capabilities provided are:

Style hot‑loading during development

Automatic compilation of Sass, Less, and Stylus

Autoprefixer for vendor prefixes

px‑to‑rem conversion

Sprite generation

Automatic extraction of image width and height

Image compression on build

Code merging and minification on build

Example Templates

ELF ships with five ready‑made templates:

Base : Minimal project structure for learning the build system.

Swiper : Vertical swipe page using the swiper library.

Switcher : Scene‑switching demo combining swiper and anime.js.

Panorama : 3D panorama example built with three.js and orientation.js, supporting device‑orientation controls.

Video : Basic mobile video playback using the HTML video tag.

These templates allow rapid project bootstrapping, and developers can customize them further.

Common Components

ELF also provides reusable components such as: elf-preloader.js: Preloads images and audio assets. elf-orientation.js: Handles device orientation events.

Conclusion

The project originated from a collection of typical examples, was refactored twice, and draws inspiration from create‑react‑app for its webpack configuration. Future plans include extracting the template module (similar to vue‑cli) and offering a GUI built with Electron.

Users are encouraged to try ELF, report issues, submit pull requests, or fork the repository. The source code is hosted on GitHub.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIAutomationwebpackHTML5project scaffolding
Aotu Lab
Written by

Aotu Lab

Aotu Lab, founded in October 2015, is a front-end engineering team serving multi-platform products. The articles in this public account are intended to share and discuss technology, reflecting only the personal views of Aotu Lab members and not the official stance of JD.com Technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.