npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@clavis/lfr-js-portlet-utils

v1.4.2

Published

provides the webpack config

Downloads

35

Readme

Improves your development with portlets that are created with yo liferay-js 🥳🎉

Tool, which downloads a liferay page from a liferay portal and configures a webpack with the fetched index.html. Which automatically loads your index.js from your js-portlet into webpack.

Advantages of lfr-js-start to the lnbs-start:

  • You are in the context of a liferay page
  • You have all the window.Liferay.* functions
  • You get the correct Language keys
  • You have the original config of the portlet
  • Vue and Typescript files work

Video how it works: https://www.youtube.com/watch?v=qO-LYsQ_6Ac

How to Use

How to install

npm install --save-dev @clavis/lfr-js-portlet-utils

Add a script call to the package.json

  "scripts": {
    "start": "lfr-js-start"
  }

Place and Configure Portlet

Deploy your portlet on the Liferay instance and place it on the root, so you see it when you call 'localhost:8080' for example. Be sure the page is public. Authorization is not supported so far.

Run

npm run start

Example usage

https://github.com/faragos/lfr-js-portlet-example

Config

You can configure the npm task with a 'liferay.portlet.config.js' in the root of the module. Here is the default config, which will be taken when no custom config is found:

module.exports = {
  protocol: 'http',
  host: 'localhost',
  originPort: 8080,
  port: 3000,
  remove: {
    selector: '[id^=js-portlet-] + script'
  },
  initCall: {
    selector: '[id^=js-portlet-] + script',
    id: 'portletElementId'
  },
  sources: {
    js: '/src/index.js'
  },
  user: '[email protected]',
  password: 'test'
}

But there is also the possibility to only configure the wrong values and your and the default config get merged

protocol

Used to find the protocol which your Portal runs

host

Used to find the host on which your Portal runs

originPort

Used to find the port on which your Portal runs

originAbsoluteUrl

Used to request static resources from your Portal

port

Specifies on which port webpack runs

remove

Remove groups all configs of which parts of the fetched index.html needs to be removed

selector

Specifies a typical selector like in 'jQuery' to find all the things that need to be removed on the fetched index.html

initCall

The initcall attribute groups all configs of the extraction of the configs from the portal. Through this init config we can extract the configuration in the portal and use it in our webpack

selector

Specifies a typical selector like in 'jQuery' to find the part in which the init call is fired for the js-portlet

portletElementId

Specifies which attribute of the parsed config is the id.

sources

The sources attribute groups all the attributes which depend on the sources

js

This is the main js file. The entrypoint for webpack.

user

Specifies the username/email with that you can log in. Currently, used to set a variable called "LIFERAY_USER"
Default is "[email protected]"
Careful this variable isn't available in the deployment on the liferay!

password

Specifies the password for the user you want to log in. Currently, used to set a variable called "LIFERAY_PASSWORD"
Default value is "test"
Careful this variable isn't available in the deployment on the liferay!

Common problems

Enable CORS

If you have some problems with CORS maybe you need to configure Liferay to allow some requests from a different endpoint:. More infos in the Liferay documentation: https://help.liferay.com/hc/en-us/articles/360030377272-Configuring-CORS

XSRF-Token

Liferay protects itself with a XSRF-Token. Also known as authToken. Obviously you can't get that token on another site, because that's the idea of an XSRF-Token. To prevent this you can either work with Basic-auth (because it's only local). If you use BasicAuth you can use the password and login which you can configure in the liferay.portlet.config.js.

I think you could also register an OAuth 2 Application in Liferay, but I never tried that so far.

You can also deactivate the whole checking of the authToken, but that is a little too much:

auth.token.check.enabled=false