-
Notifications
You must be signed in to change notification settings - Fork 40
Running build npm scripts
⚠️ The contents of this wiki have been migrated to theliferay/liferay-frontend-projectsmonorepo and more specifically to the to themaintenance/projects/js-toolkit/docsdirectory. Development and updates will continue there, and this repo will be archived (ie. switched to read-only mode).
Once a project is generated, all actions are run by using npm scripts. To run such scripts just type:
npm run [name of script] ↩The following sections describe the available scripts.
This script places the output of liferay-npm-bundler in your project's dist subfolder. The standard output contains a JAR file, named upon the name and version of the project, that can be manually deployed to Liferay.
Note that intermediate files are generated in the build subfolder, too.
This script is available if you configured your Liferay instance when the generator was run by replying to the following questions:
? Do you have a local installation of Liferay for development? Yes
? Where is your local installation of Liferay placed? /liferay
It copies the resulting JAR from the build script to your local Liferay installation so that you don't need to deploy it by hand.
This script lets you test the application in a local webpack installation instead of a Liferay server. This approach has the benefit that development is much faster because you can see live changes without any need to deploy.
On the other hand, you are not running the application in a Liferay instance, so you won't have access to any of its APIs or resources. That is: you are run in a plain browser environment, not a Liferay one.
If you need to access Liferay APIs and still want to use the start script, you will have to wrap your access to Liferay resources into some piece of code that can mimick them when running from start, and pass on the calls when running inside Liferay. This can be complex to setup, but in the long term it will have more benefits, as it will allow you to test your projects more easily and will decouple your code from the runtime platform.
This script lets you translate localization labels with the aid of Microsoft Translator Text API.
Once you generate a project, if you replied yes to the question:
? Do you want to add localization support?
a Language.properties file inside features/localization directory will be created. This file contains the localization labels for the Liferay I18N system and it is initialized in English as the default language.
You know it is the default language because the
Language.propertieshas no locale suffix. If it was targeted at, for instance, Spanish, it would be namedLanguage_es.properties.
Additionally, two keys will be written to your .npmbuildrc file: translatorTextKey and supportedLocales. These keys are to be used by the translate npm script. The first one specifies the credentials for the Microsoft Translator Service while the second one is an array listing all the locales your application supports.
Using the translate script is as simple as filling these two keys and executing it. Once that's done, the script will:
- Create all missing
Language_xx.propertiesfiles according to the contents of thesupportedLocalesarray. - Warn about
Language_xx.propertiesfiles existing in your project but not listed undersupportedLocales. - Make sure that all labels in the default
Language.propertiesfile are translated to all supported locales and written into their correspondingLanguage_xx.propertiesfiles.