oo

Fragments Toolkit Command Reference

Note

The Fragments Toolkit is deprecated as of Liferay 2024.Q1+/Portal 7.4 GA112+. See Alternatives for the Fragments Toolkit for more information.

The Fragments Toolkit can connect to your currently running Liferay DXP instance to import and export fragments. You can even have Fragments that you create with the toolkit imported into Portal automatically. These commands are available:

Command Description
npm run add-collection Create a new collection to organize fragments. Referred as Fragment Sets in the platform.
npm run add-fragment Add a component, input, or React fragment to a new or existing collection.
npm run add-fragment-composition Add a new fragment composition to a new or existing collection.
npm run add-page-template Create a new display page template, page template, or master page.
npm run build Compile .sass or .scss file specified in fragment.json’s cssPath key, storing the compiled CSS code in build/liferay-fragments. Only compiled CSS is stored and no SCSS is saved in the database. External fragments should be stored in an external repository.
npm run compress Create a .zip file that can be manually imported into Portal.
npm run export Get collections and fragments from a running server
npm run import Send the collections and fragments from your current project to a running server. If your Fragment’s configuration JSON (if available) is invalid, the import fails and provides an error message.
npm run import:watch Automatically import Collections and Fragments into Portal as they are created or modified.
npm run preview Liferay DXP 7.2 SP1+/Portal 7.2 GA2+ Preview a Fragment before importing. Changes made to the fragment are auto-reloaded to display updates. This feature requires the installation of the OAuth 2 plugin in your portal instance.
Note

You can see all of the available tasks inside the scripts section in the Fragment Set project’s package.json.

With these tools at your disposal, you can efficiently manage creating and editing Page Fragments from the command line in your local environment.

Feature: