@lengkapp/la-build
v0.0.4
Published
๐ **la-build** is a high-performance build tool powered by **esbuild**, **PurgeCSS**, **CSSO**, and **Hono SSG**.
Readme
@lengkapp/la-build
๐ la-build is a high-performance build tool powered by esbuild, PurgeCSS, CSSO, and Hono SSG.
It automatically bundles your JavaScript/TypeScript code, generates static HTML from components/Hono apps, recursively analyzes all imported dependencies for unused CSS rules, minifies all assets, and writes them directly to your build directory.
โจ Features
- โก Lightning Fast: Powered by
esbuildfor ultra-fast JS/TS bundling. - ๐๏ธ Static Site Generation (SSG): Render JSX/TSX components or Hono apps to static HTML output directly.
- ๐งน Automatic CSS Purging: Scans all source dependency files found during the JS/TS dependency resolution step to strip unused CSS rules using PurgeCSS.
- ๐ฆ Asset Minification: Compresses JS, purged CSS (via CSSO), and HTML (via html-minifier-terser).
- ๐ ๏ธ Configurable: Run multiple entry points (
.html,.tsx,.jsx,.ts,.js) with flexible inputs and outputs in a single build command.
๐ฆ Installation
Install la-build into your project as a development dependency:
npm install -D @lengkapp/la-build
# or
yarn add -D @lengkapp/la-build
# or
pnpm add -D @lengkapp/la-build
๐ Quick Start
1. Create a Configuration File
Create a config.build.js file in the root directory of your project:
// config.build.js
export default [
// 1. TSX Component / Hono App -> Static HTML + Purged CSS
{
entryPage: 'src/pages/home.tsx',
htmlOutput: 'public/home.html',
cssInput: 'src/styles/global.css',
cssOutput: 'public/global.css',
minified: true, // Optional, defaults to true
},
// 2. TSX / JS App -> Bundled JS + Purged CSS
{
entryPage: 'src/index.tsx',
jsOutput: 'dist/index.js',
cssInput: 'src/styles/global.css',
cssOutput: 'public/global.css',
},
// 3. Static HTML -> Purged CSS & HTML Minification
{
entryPage: 'public/admin.html',
cssInput: 'src/styles/admin.css',
cssOutput: 'public/admin.css',
},
];
2. Add a Script to package.json
Add the build command to your package.json:
{
"scripts": {
"build": "la-build --config config.build.js"
}
}
3. Run the Build
Execute the build using your package manager or npx:
npm run build
# OR directly via npx
npx @lengkapp/la-build --config config.build.js
โ๏ธ Configuration Options
| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| entryPage | string | Yes | Path to the JS/TS file (.tsx, .ts, .jsx, .js) or static .html entry file. |
| cssInput | string | Optional | Path to the source CSS file to be purged and minified. |
| cssOutput | string | Optional | Destination path for the minified, purged CSS output. |
| jsOutput | string | Optional | Destination path for the bundled JS file. |
| htmlOutput | string | Optional | File path (.html) or directory path for SSG static HTML generation. |
| componentName | string | Optional | Specific named export to render during SSG (defaults to default export or the first exported function). |
| minified | boolean | Optional | Enables/disables minification for JS, CSS, and HTML assets simultaneously. Default is true. |
deploy
npm whoami
npm login
npm publish --access public๐ License
MIT
