@liferay-editor-custom-fields/framework 7.4.2 → 7.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -9
- package/build/static/index.d.ts +2 -0
- package/build/static/index.js +1 -0
- package/build/static/messagingEvents/fireFragmentConfigOnLoad.d.ts +1 -0
- package/build/static/messagingEvents/fireImageOnChange.d.ts +1 -0
- package/build/static/messagingEvents/fireWebContentFieldsOnLoad.d.ts +1 -0
- package/{src/observers/index.ts → build/static/observers/index.d.ts} +1 -2
- package/build/static/observers/observeFragmentConfig.d.ts +1 -0
- package/build/static/observers/observePreviewImage.d.ts +2 -0
- package/build/static/observers/observeWebContentFields.d.ts +1 -0
- package/build/static/types/ContentType.type.d.ts +1 -0
- package/build/static/util/debounce.d.ts +1 -0
- package/build/static/util/getContentImageInput.d.ts +1 -0
- package/build/static/util/getFieldByLabel.d.ts +8 -0
- package/build/static/util/getPreviewImage.d.ts +1 -0
- package/{src/util/index.ts → build/static/util/index.d.ts} +1 -2
- package/build/static/util/setReactDomInputValue.d.ts +8 -0
- package/package.json +6 -3
- package/eslint.config.mjs +0 -11
- package/src/index.ts +0 -34
- package/src/messagingEvents/fireFragmentConfigOnLoad.ts +0 -2
- package/src/messagingEvents/fireImageOnChange.ts +0 -4
- package/src/messagingEvents/fireWebContentFieldsOnLoad.ts +0 -2
- package/src/observers/observeFragmentConfig.ts +0 -27
- package/src/observers/observePreviewImage.ts +0 -22
- package/src/observers/observeWebContentFields.ts +0 -24
- package/src/types/ContentType.type.ts +0 -1
- package/src/util/debounce.ts +0 -9
- package/src/util/getContentImageInput.ts +0 -5
- package/src/util/getFieldByLabel.ts +0 -25
- package/src/util/getPreviewImage.ts +0 -10
- package/src/util/setReactDomInputValue.ts +0 -22
- package/tsconfig.json +0 -21
- package/webpack.config.js +0 -62
package/README.md
CHANGED
|
@@ -1,28 +1,50 @@
|
|
|
1
1
|
# Liferay Custom Fields Framework
|
|
2
2
|
|
|
3
|
-
The engine behind Liferay
|
|
3
|
+
The engine behind Liferay Editor Custom Fields.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Before You Start
|
|
6
|
+
|
|
7
|
+
Any client extension using this framework should not run on a production or pre-prod staging environment. It is only intended for the fragment and web content editors. Any JS that will end up on the page should be elsewhere, either in a separate client extension or in the fragment/web content template.
|
|
8
|
+
|
|
9
|
+
You only need this if you are creating a new Liferay Editor Custom Fields package, otherwise it is provided as a dependency on existing ones.
|
|
6
10
|
|
|
7
11
|
## Getting Started
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
- Install @liferay-editor-custom-fields/framework
|
|
14
|
+
- Make sure the version matches the minor version of Liferay you are using
|
|
15
|
+
- For example `yarn add @liferay-editor-custom-fields/framework@~7.4.0` for Liferay 7.4.
|
|
16
|
+
- In the index.ts of your app:
|
|
17
|
+
- Declare the Liferay global object
|
|
18
|
+
- Import the default exported function from @liferay-editor-custom-fields/framework. You can call it something short like initFramework();
|
|
19
|
+
- Create a default exported function of your own and call that function
|
|
20
|
+
- Write a Liferay.on event subscriber for each event that your app will be using. See the Events section of this document for a list of events.
|
|
10
21
|
|
|
22
|
+
```
|
|
23
|
+
declare const Liferay;
|
|
11
24
|
|
|
12
|
-
|
|
25
|
+
import initFramework from '@liferay-editor-custom-fields/framework';
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
const initImageTools: () => void = () => {
|
|
28
|
+
initFramework();
|
|
29
|
+
Liferay.on('EditorCustomFields_WebContentFields_OnLoad', ()=>{});
|
|
30
|
+
Liferay.on('EditorCustomFields_FragmenConfig_OnLoad', ()=>{});
|
|
31
|
+
Liferay.on('EditorCustomFields_Image_OnChange', ()=>{});
|
|
32
|
+
}
|
|
33
|
+
export default initImageTools;
|
|
34
|
+
```
|
|
15
35
|
|
|
16
|
-
|
|
36
|
+
## Events
|
|
17
37
|
|
|
18
38
|
Use Liferay.on to subscribe to these events:
|
|
39
|
+
|
|
19
40
|
- `EditorCustomFields_WebContentFields_OnLoad` - Fires when web content field DOM is loaded.
|
|
20
41
|
- `EditorCustomFields_FragmenConfig_OnLoad` - Fires when a new Fragment config is loaded on the right pane of a page editor.
|
|
21
42
|
- `EditorCustomFields_Image_OnChange` - Fires when an lfr-editable image or Web Content image is changed.
|
|
22
43
|
|
|
23
|
-
|
|
44
|
+
## Helper functions
|
|
45
|
+
|
|
46
|
+
The helper functions below are available for import in any file. For example, to use the getFieldByLabel helper you would use `import { getFieldByLabel } from "@liferay-editor-custom-fields/framework";`
|
|
24
47
|
|
|
25
|
-
The helper functions below are children of Liferay.editorCustomFields
|
|
26
48
|
- `debounce(callback:function, wait:number)` - A simple callback function
|
|
27
49
|
- `getContentImageInput(label:string)` - Gets the metadata input field associated with the web content image.
|
|
28
50
|
- `getFieldByLabel(label:string)` - Uses Xpath to get an input field by its label. Usually used to append a GUI element.
|
|
@@ -31,4 +53,4 @@ The helper functions below are children of Liferay.editorCustomFields
|
|
|
31
53
|
|
|
32
54
|
## License
|
|
33
55
|
|
|
34
|
-
MIT Licensed. Copyright (c) Xtivia 2026.
|
|
56
|
+
MIT Licensed. Copyright (c) Xtivia 2026.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{c:()=>d});const r=(e,t)=>{let r=null;return(...o)=>{window.clearTimeout(r),r=window.setTimeout(()=>{e(...o)},t)}},o=()=>{Liferay.fire("EditorCustomFields_Image_OnChange")},i=()=>{const e=document?.querySelector("#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__topper.active"),t=e?.querySelector(".page-editor__topper.active img.page-editor__editable, .image-picker-preview>img");return t},n=()=>document.querySelector('input[name^="_com_liferay_journal_web_portlet_JournalPortlet_ddm$$Image"]'),s=e=>{Liferay.editorCustomFields.imageObserver&&Liferay.editorCustomFields.imageObserver.disconnect?.();const t="fragment"===e?i():n();if(e&&t&&!Liferay.editorCustomFields.imageObserver){const e=r(()=>o(),500);Liferay.editorCustomFields.imageObserver=new MutationObserver(e);const i={attributes:!0,childList:!1,subtree:!1};Liferay.editorCustomFields.imageObserver.observe(t,i)}o()},a=()=>{const e=document.querySelector(".page-editor__item-configuration-sidebar");if(e){Liferay.editorCustomFields.fragmentObserver&&Liferay.editorCustomFields.fragmentObserver.disconnect?.();const t=r(()=>{s("fragment"),Liferay.fire("EditorCustomFields_FragmenConfig_OnLoad")},500);Liferay.editorCustomFields.fragmentObserver=new MutationObserver(t);const o={attributes:!1,childList:!0,subtree:!1};Liferay.editorCustomFields.fragmentObserver.observe(e,o)}},l=e=>{const t=document.querySelector("#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__item-configuration-sidebar"),r=document.evaluate(`//label[text()='${e}']`,t,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return r?.closest(".form-group, .field-wrapper")?.querySelector("input")||r?.nextElementSibling?.querySelector("input")||r?.nextSibling},u=(e,t)=>{e.focus(),Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),document.body.focus(),e.dispatchEvent(new Event("blur",{bubbles:!0}))},d=()=>{const e=()=>{(()=>{const e=document.querySelector("#_com_liferay_journal_web_portlet_JournalPortlet_fieldsContent");if(e){Liferay.editorCustomFields.webContentObserver&&Liferay.editorCustomFields.webContentObserver.disconnect?.();const t=r(()=>{s("content"),Liferay.fire("EditorCustomFields_WebContentFields_OnLoad")},500);Liferay.editorCustomFields.webContentObserver=new MutationObserver(t);const o={attributes:!1,childList:!0,subtree:!0};Liferay.editorCustomFields.webContentObserver.observe(e,o)}})(),setTimeout(a,500)};Liferay&&!Liferay?.editorCustomFields&&(Liferay.editorCustomFields={debounce:r,getFieldByLabel:l,setReactDomInputValue:u,getContentImageInput:n,getPreviewImage:i},Liferay.on("allPortletsReady",()=>{e()}),Liferay.on("endNavigate",()=>{e()}))};var c=t.c;export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fireFragmentConfigOnLoad: () => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fireImageOnChange: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fireWebContentFieldsOnLoad: () => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const observeFragmentConfig: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const observeWebContentFields: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ContentType = 'fragment' | 'content';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debounce: (callback: any, wait: any) => (...args: any[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getContentImageInput: () => HTMLInputElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getPreviewImage: () => HTMLImageElement;
|
|
@@ -3,5 +3,4 @@ import { getContentImageInput } from "./getContentImageInput";
|
|
|
3
3
|
import { getFieldByLabel } from "./getFieldByLabel";
|
|
4
4
|
import { getPreviewImage } from "./getPreviewImage";
|
|
5
5
|
import { setReactDomInputValue } from "./setReactDomInputValue";
|
|
6
|
-
|
|
7
|
-
export { debounce, getContentImageInput, getFieldByLabel, getPreviewImage, setReactDomInputValue };
|
|
6
|
+
export { debounce, getContentImageInput, getFieldByLabel, getPreviewImage, setReactDomInputValue };
|
package/package.json
CHANGED
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
"webpack-cli": "5.1.4",
|
|
16
16
|
"webpack-dev-server": "4.15.1"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
|
|
18
|
+
"files": [
|
|
19
|
+
"build"
|
|
20
|
+
],
|
|
21
|
+
"module": "./build/static/index.js",
|
|
22
|
+
"types": "./build/static/index.d.ts",
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "webpack",
|
|
22
25
|
"start": "webpack serve",
|
|
23
26
|
"watch": "tsc --watch"
|
|
24
27
|
},
|
|
25
|
-
"version": "7.4.
|
|
28
|
+
"version": "7.4.5"
|
|
26
29
|
}
|
package/eslint.config.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import eslint from "@eslint/js";
|
|
4
|
-
import { defineConfig, globalIgnores } from "eslint/config";
|
|
5
|
-
import tseslint from "typescript-eslint";
|
|
6
|
-
|
|
7
|
-
export default defineConfig(
|
|
8
|
-
eslint.configs.recommended,
|
|
9
|
-
tseslint.configs.recommended,
|
|
10
|
-
[globalIgnores(["**/*.js", "**/*.cjs", "**/*.mjs"])],
|
|
11
|
-
);
|
package/src/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
declare const Liferay;
|
|
2
|
-
|
|
3
|
-
import { observeFragmentConfig, observeWebContentFields } from "./observers";
|
|
4
|
-
import {
|
|
5
|
-
debounce,
|
|
6
|
-
getContentImageInput,
|
|
7
|
-
getFieldByLabel,
|
|
8
|
-
getPreviewImage,
|
|
9
|
-
setReactDomInputValue,
|
|
10
|
-
} from "./util";
|
|
11
|
-
|
|
12
|
-
const initFramework:()=>void = () => {
|
|
13
|
-
const startObservers = () => {
|
|
14
|
-
observeWebContentFields();
|
|
15
|
-
// Fragment element we are watching is loaded client-side, and AFAIK there is no event fired when client-side is loaded.
|
|
16
|
-
setTimeout(observeFragmentConfig, 500);
|
|
17
|
-
};
|
|
18
|
-
if (Liferay && !Liferay?.editorCustomFields) {
|
|
19
|
-
Liferay.editorCustomFields = {
|
|
20
|
-
debounce,
|
|
21
|
-
getFieldByLabel,
|
|
22
|
-
setReactDomInputValue,
|
|
23
|
-
getContentImageInput,
|
|
24
|
-
getPreviewImage,
|
|
25
|
-
};
|
|
26
|
-
Liferay.on("allPortletsReady", () => {
|
|
27
|
-
startObservers();
|
|
28
|
-
});
|
|
29
|
-
Liferay.on("endNavigate", () => {
|
|
30
|
-
startObservers();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export default initFramework;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
declare const Liferay;
|
|
2
|
-
|
|
3
|
-
import { fireFragmentConfigOnLoad } from "../messagingEvents/fireFragmentConfigOnLoad";
|
|
4
|
-
import { debounce } from "../util";
|
|
5
|
-
|
|
6
|
-
import { observePreviewImage } from "./observePreviewImage";
|
|
7
|
-
|
|
8
|
-
export const observeFragmentConfig = () => {
|
|
9
|
-
const sidePanelQuery = ".page-editor__item-configuration-sidebar";
|
|
10
|
-
const sidePanelEl: HTMLDivElement = document.querySelector(
|
|
11
|
-
sidePanelQuery
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
if (sidePanelEl) {
|
|
15
|
-
if (Liferay.editorCustomFields.fragmentObserver) {
|
|
16
|
-
Liferay.editorCustomFields.fragmentObserver.disconnect?.();
|
|
17
|
-
}
|
|
18
|
-
const debouncedAddButton = debounce(() => {
|
|
19
|
-
observePreviewImage('fragment');
|
|
20
|
-
fireFragmentConfigOnLoad();
|
|
21
|
-
}, 500);
|
|
22
|
-
Liferay.editorCustomFields.fragmentObserver = new MutationObserver(debouncedAddButton);
|
|
23
|
-
const observer = Liferay.editorCustomFields.fragmentObserver;
|
|
24
|
-
const config = { attributes: false, childList: true, subtree: false };
|
|
25
|
-
observer.observe(sidePanelEl, config);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare const Liferay;
|
|
2
|
-
|
|
3
|
-
import { fireImageOnChange } from "../messagingEvents/fireImageOnChange";
|
|
4
|
-
import { ContentType } from "../types/ContentType.type";
|
|
5
|
-
import { debounce, getContentImageInput, getPreviewImage } from "../util";
|
|
6
|
-
|
|
7
|
-
export const observePreviewImage = (contentType: ContentType) => {
|
|
8
|
-
if(Liferay.editorCustomFields.imageObserver){
|
|
9
|
-
Liferay.editorCustomFields.imageObserver.disconnect?.();
|
|
10
|
-
}
|
|
11
|
-
// For when image changes
|
|
12
|
-
const elToObserve = contentType === 'fragment' ? getPreviewImage() : getContentImageInput();
|
|
13
|
-
if (contentType && elToObserve && !Liferay.editorCustomFields.imageObserver) {
|
|
14
|
-
const debouncedAddContentBlurhash = debounce(() => fireImageOnChange(), 500);
|
|
15
|
-
Liferay.editorCustomFields.imageObserver = new MutationObserver(debouncedAddContentBlurhash);
|
|
16
|
-
const observer = Liferay.editorCustomFields.imageObserver
|
|
17
|
-
const config = { attributes: true, childList: false, subtree: false };
|
|
18
|
-
observer.observe(elToObserve, config);
|
|
19
|
-
}
|
|
20
|
-
// For when image is already present on load
|
|
21
|
-
fireImageOnChange();
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
declare const Liferay;
|
|
2
|
-
|
|
3
|
-
import { fireWebContentFieldsOnLoad } from "../messagingEvents/fireWebContentFieldsOnLoad";
|
|
4
|
-
import { debounce } from "../util";
|
|
5
|
-
import { observePreviewImage } from "./observePreviewImage";
|
|
6
|
-
|
|
7
|
-
export const observeWebContentFields = () => {
|
|
8
|
-
const fieldsContainerEl: HTMLDivElement = document.querySelector(
|
|
9
|
-
"#_com_liferay_journal_web_portlet_JournalPortlet_fieldsContent",
|
|
10
|
-
);
|
|
11
|
-
if (fieldsContainerEl) {
|
|
12
|
-
if (Liferay.editorCustomFields.webContentObserver) {
|
|
13
|
-
Liferay.editorCustomFields.webContentObserver.disconnect?.();
|
|
14
|
-
}
|
|
15
|
-
const debouncedFieldEvent = debounce(() => {
|
|
16
|
-
observePreviewImage('content');
|
|
17
|
-
fireWebContentFieldsOnLoad();
|
|
18
|
-
}, 500);
|
|
19
|
-
Liferay.editorCustomFields.webContentObserver = new MutationObserver(debouncedFieldEvent);
|
|
20
|
-
const observer = Liferay.editorCustomFields.webContentObserver
|
|
21
|
-
const config = { attributes: false, childList: true, subtree: true };
|
|
22
|
-
observer.observe(fieldsContainerEl, config);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type ContentType = 'fragment' | 'content';
|
package/src/util/debounce.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export const getContentImageInput = () => {
|
|
2
|
-
const contentImageInputQuery = 'input[name^="_com_liferay_journal_web_portlet_JournalPortlet_ddm$$Image"]';
|
|
3
|
-
const contentImageInput: HTMLInputElement = document.querySelector(contentImageInputQuery);
|
|
4
|
-
return contentImageInput;
|
|
5
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Uses xpath to get a LR field by label
|
|
3
|
-
* since there is no attribute that corresponds with field name or key
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
type GetFieldByLabel = (label:string) => HTMLInputElement;
|
|
7
|
-
export const getFieldByLabel:GetFieldByLabel = (label) => {
|
|
8
|
-
const parentEl = document.querySelector(
|
|
9
|
-
"#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__item-configuration-sidebar",
|
|
10
|
-
);
|
|
11
|
-
const match = document.evaluate(
|
|
12
|
-
`//label[text()='${label}']`,
|
|
13
|
-
parentEl,
|
|
14
|
-
null,
|
|
15
|
-
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
16
|
-
null,
|
|
17
|
-
).singleNodeValue as HTMLElement;
|
|
18
|
-
|
|
19
|
-
const inputEl =
|
|
20
|
-
match?.closest(".form-group, .field-wrapper")?.querySelector("input") ||
|
|
21
|
-
match?.nextElementSibling?.querySelector("input") ||
|
|
22
|
-
match?.nextSibling;
|
|
23
|
-
|
|
24
|
-
return inputEl as HTMLInputElement;
|
|
25
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const getPreviewImage = () => {
|
|
2
|
-
const parentEl:HTMLDivElement = document?.querySelector(
|
|
3
|
-
"#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__topper.active",
|
|
4
|
-
);
|
|
5
|
-
const previewImage:HTMLImageElement = parentEl?.querySelector(
|
|
6
|
-
".page-editor__topper.active img.page-editor__editable, .image-picker-preview>img",
|
|
7
|
-
) as HTMLImageElement;
|
|
8
|
-
|
|
9
|
-
return previewImage;
|
|
10
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The fragment editor config inputs use react DOM
|
|
3
|
-
* So setting input element value doesn't work
|
|
4
|
-
*
|
|
5
|
-
* @param {element} inputEl
|
|
6
|
-
* @param {string} value
|
|
7
|
-
*/
|
|
8
|
-
export const setReactDomInputValue = (inputEl:HTMLInputElement, value:string) => {
|
|
9
|
-
inputEl.focus();
|
|
10
|
-
const nativeValueSetter = Object.getOwnPropertyDescriptor(
|
|
11
|
-
window.HTMLInputElement.prototype,
|
|
12
|
-
"value",
|
|
13
|
-
).set;
|
|
14
|
-
nativeValueSetter.call(inputEl, value);
|
|
15
|
-
|
|
16
|
-
inputEl.dispatchEvent(new Event("input", { bubbles: true }));
|
|
17
|
-
inputEl.dispatchEvent(new Event("change", { bubbles: true }));
|
|
18
|
-
|
|
19
|
-
document.body.focus();
|
|
20
|
-
|
|
21
|
-
inputEl.dispatchEvent(new Event("blur", { bubbles: true }));
|
|
22
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"lib": [
|
|
6
|
-
"DOM",
|
|
7
|
-
"ES2020"
|
|
8
|
-
],
|
|
9
|
-
"module": "ES2020",
|
|
10
|
-
"moduleResolution": "node",
|
|
11
|
-
"outDir": "./build/static",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"sourceMap": false,
|
|
14
|
-
"target": "ES2020",
|
|
15
|
-
"types": [
|
|
16
|
-
]
|
|
17
|
-
},
|
|
18
|
-
"include": [
|
|
19
|
-
"./src/**/*"
|
|
20
|
-
]
|
|
21
|
-
}
|
package/webpack.config.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
|
|
3
|
-
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const webpack = require("webpack");
|
|
8
|
-
const ESLintPlugin = require("eslint-webpack-plugin");
|
|
9
|
-
|
|
10
|
-
const DEVELOPMENT = process.env.NODE_ENV === "development";
|
|
11
|
-
const WEBPACK_SERVE = !!process.env.WEBPACK_SERVE;
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
devServer: {
|
|
15
|
-
headers: {
|
|
16
|
-
"Access-Control-Allow-Origin": "*",
|
|
17
|
-
},
|
|
18
|
-
port: 3000,
|
|
19
|
-
},
|
|
20
|
-
devtool: DEVELOPMENT ? "source-map" : false,
|
|
21
|
-
entry: {
|
|
22
|
-
index: "./src/index.ts",
|
|
23
|
-
},
|
|
24
|
-
experiments: {
|
|
25
|
-
outputModule: true,
|
|
26
|
-
},
|
|
27
|
-
mode: DEVELOPMENT ? "development" : "production",
|
|
28
|
-
module: {
|
|
29
|
-
rules: [
|
|
30
|
-
{
|
|
31
|
-
test: /\.ts$/i,
|
|
32
|
-
use: ["ts-loader"],
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
optimization: {
|
|
37
|
-
minimize: !DEVELOPMENT,
|
|
38
|
-
},
|
|
39
|
-
output: {
|
|
40
|
-
clean: true,
|
|
41
|
-
environment: {
|
|
42
|
-
dynamicImport: true,
|
|
43
|
-
},
|
|
44
|
-
filename: WEBPACK_SERVE ? "[name].js" : "[name].js",
|
|
45
|
-
library: {
|
|
46
|
-
type: "module",
|
|
47
|
-
},
|
|
48
|
-
path: path.resolve("build", "static"),
|
|
49
|
-
},
|
|
50
|
-
plugins: [
|
|
51
|
-
new ESLintPlugin({
|
|
52
|
-
files: "src/**/*.ts",
|
|
53
|
-
overrideConfigFile: `eslint.config.mjs`,
|
|
54
|
-
}),
|
|
55
|
-
new webpack.optimize.LimitChunkCountPlugin({
|
|
56
|
-
maxChunks: 1,
|
|
57
|
-
}),
|
|
58
|
-
],
|
|
59
|
-
resolve: {
|
|
60
|
-
extensions: [".js", ".ts"],
|
|
61
|
-
},
|
|
62
|
-
};
|