Liferay NPM Bundler Improved

1.5.1 · active · verified Sun Apr 19

liferay-npm-bundler-improved is an unofficial, high-speed alternative to the official liferay-npm-bundler, designed to accelerate the development of Liferay portlets. Currently stable at version 1.5.1, its release cadence is feature-driven, with significant updates recently including beta phases for watch mode and localization. Key differentiators include drastically faster build times (around 0.1s on modern hardware) compared to the official bundler, an enhanced developer experience through a 'watch mode' with live instance replacement (primarily for Vite projects), comprehensive error reporting for common issues like missing `package.json` keys, and experimental localization support for `Liferay.Language.get()` functions within portlets. It also offers optional deployment automation and support for portlet instance configuration.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates `liferay-npm-bundler-improved` setup in `package.json` scripts, including development with watch/deploy mode and a production build incorporating source and asset copying. Requires Vite for watch mode.

{
  "name": "my-liferay-portlet",
  "version": "1.0.0",
  "description": "A sample Liferay portlet using liferay-npm-bundler-improved.",
  "main": "src/index.js",
  "scripts": {
    "dev": "liferay-npm-bundler-improved -w --deploy",
    "build": "liferay-npm-bundler-improved --copy-sources --copy-assets"
  },
  "keywords": ["liferay", "portlet"],
  "devDependencies": {
    "liferay-npm-bundler-improved": "^1.5.1",
    "vite": "^5.0.0" // Required for watch mode
  },
  "license": "MIT"
}

// To install dependencies:
// pnpm i --D liferay-npm-bundler-improved vite

// To use in development with watch mode and deployment (requires .env with LIFERAY_DEPLOYMENT_PATH):
// Set environment variable: LIFERAY_DEPLOYMENT_PATH=/path/to/your/liferay/deploy
// pnpm dev

// To run a production build:
// pnpm build

view raw JSON →