Importing resources to a webapp

vishet
vishet Registered Posts: 17 ✭✭✭✭

Hi,

My objective is to create a Simple HTML/JS webapp that has multiple HTML/CSS/JS files. I tried creating a resource folder under the plugin as follows '/plugins/<pluginid>/resource/<htmlfile>' and DSS was not able to reference that resource.

On the other hand, when I place the resources under /local/static and reference them, it works just fine. Anything that I am doing wrong?

Best Answers

  • StanG
    StanG Dataiker, Registered Posts: 52 Dataiker
    Answer ✓

    Hi,
    The resource folder is located at 'plugins/dev/plugin-id/resource' or 'plugins/installed/plugin-id/resource' depending on whether it is a dev or an installed plugin (in your case it's a dev plugin), but to reference it you should use 'plugins/plugin-id/resource'.
    Maybe it was the issue. Let me know

  • StanG
    StanG Dataiker, Registered Posts: 52 Dataiker
    Answer ✓

    What if you try as reference path: "../../resource/PATH_TO_HTML" ?

Answers

  • vishet
    vishet Registered Posts: 17 ✭✭✭✭

    Thank you for the response.

    I tried both. the /dev/ and the /installed/ as part of the locator /plugins/dev/<pluginid>/resource/<filename>

    None of that worked. I am not sure if it is a problem with my dss instance or if there is s config issue.

  • vishet
    vishet Registered Posts: 17 ✭✭✭✭

    Still nothing.

    I tried accessing the body.html via http://localhost:11200/plugins/<pluginid>/<webappid>/body.html and it showed page not found. If I am not wrong, this should definitely return body.html, but it doesn't

  • adamnieto
    adamnieto Neuron 2020, Neuron, Registered, Neuron 2021, Neuron 2022, Neuron 2023 Posts: 90 Neuron
    edited July 2024

    Hi @vishet
    ,

    So when I want to reference pages from the 'resource' folder inside of

    /plugins/development/<plugin-id>/editor

    I add a script tag in my HTML file for my web app that follows this format:

    <script src="/plugins/ADD_YOUR_PLUGIN_ID_HERE/resource/js/angular.min.js" type="text/javascript"></script>

    The above example is how I would load a angular.min.js file.

    So following your example, I believe it would be something like this:

    http://localhost:11200/plugins/<pluginid>/resource/body.html

    Hope this helps!

Setup Info
    Tags
      Help me…