ain / smartbanner.js

Customisable smart app banner for iOS and Android
https://npmjs.com/package/smartbanner.js
GNU General Public License v3.0
619 stars 178 forks source link

Js and CSS files are throwing error #709

Closed omvaishnav closed 10 months ago

omvaishnav commented 10 months ago

Steps to reproduce:

  1. Added below lines in index.html after installing the package

What happens: Files not included properly and showing error - Uncaught SyntaxError: Unexpected token '<' (at smartbanner.min.js:1:1)

What should happen: both js and css files should be exported from the package.

How can we give direct node_modules package file path as it's outside of root?

ain commented 10 months ago

Inclusion of the script is of course dependant on the individual project setup. The example use-case in the README is illustrational.

Please make sure that the smartbanner.min.js and smartbanner.min.css are placed with the rest of your CSS and JS assets so that the files are publicly accessible for end-users.

omvaishnav commented 10 months ago

Do we need to manually copy both files from the package and place them in the assets folder? If that's the case, what happens when the package receives updates to these files? Is there a more efficient way to handle updates and ensure that our assets stay synchronized with the package changes?

ain commented 10 months ago

It's a task that your local setup has to consider during the build and/or asset compilation. Exposing gigabytes of node_modules to public is not a good idea.

omvaishnav commented 10 months ago

Thank you, Ain, for providing clarification. I have an additional question. Is there a way to configure a global class for either the <html> or <body> tag when the smart banner is active?

ain commented 10 months ago

Good question.

It is not directly possible, but what you could do is:

  1. use custom design modifier which adds a specific class not to the body or html, but to the wrapper element which smartbanner is added to.
  2. use smartbanner API and listen to init of smartbanner and add the global class to html or body automatically whenever you have the smartbanner added, e.g.:
document.addEventListener('smartbanner.init', javascript_function_to_add_class_to_body);