Page 1 of 1

How I use the existing .js modules in customization temlate?

Posted: Fri Apr 09, 2021 4:54 pm
by tmakita
Hi,

I'm developing Oxygen WebHelp custom template that uses external search engine (AWS Elasticsearch). Currently basic connection test has done successfully and I could get the search query results from external search engine by JSON format.

Then now is the time to develop search result pages. I started this work and found I need existing Oxygen JavaScript modules to develop search result pages. For instance following JavaScript module is needed.
  • webhelp-responsive/app/localization/localization.js
  • webhelp-responsive/app/search/searchHistoryItems.js


The former exists in the output directly so that I added it simply to [custom search template]/js/template-main.js, but the latter is not found in the output directly (may be because I'm developing alternative search templates), as the result I manually copied searchHistoryItems.js into the [custom search template]/js folder.

[custom search template]/js/template-main.js

Code: Select all

define(['require'], function (require) {
    require([
        './suggest',
        './search-es',
        './build-param',
        './searchHistoryItems',
        '../../../oxygen-webhelp/app/localization/localization'
    ]);
});
However I got the following error when I execute the search in the browser development console.
Failed to load resource: the server responded with a status of 404 (Not Found) http://wh/GR2-640/out/webhelp-responsiv ... 2021030218
require.js:5 Uncaught Error: Script error for "searchHistoryItems", needed by: template-base-dir/js/search-es
http://requirejs.org/docs/errors.html#scripterror
at makeError (require.js:5)
at HTMLScriptElement.onScriptError (require.js:5)
What is the right way to use (or load) existing Oxygen JavaScript modules from the custom template JavaScript?

Regards,

Re: How I use the existing .js modules in customization temlate?

Posted: Fri Apr 09, 2021 5:02 pm
by tmakita
temlate ⇒ template

Re: How I use the existing .js modules in customization temlate?

Posted: Mon Apr 12, 2021 11:48 am
by tmakita
Solved!
  • Add extension plug-in that implements "ant.import" and changing "com.oxygenxml.responsive.internal.target.dependencies.topics.html"
  • Implement custom .js file "copy" in the added build process.