Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to include external scripts to the application #2121

Closed
Sumitha-95 opened this issue Feb 20, 2019 · 4 comments
Closed

How to include external scripts to the application #2121

Sumitha-95 opened this issue Feb 20, 2019 · 4 comments

Comments

@Sumitha-95
Copy link

Hi,
I want to add an external library to my enact application.How can i do that.
AFAIK there's no way to include external scripts in enact. Ex:

<script type="text/javascript" src="/app/script.js"></script>

How can i do that using enact js.

@sugardave
Copy link
Contributor

sugardave commented Feb 20, 2019

I haven't tried this, but I think you should be able to get it working.

If it's a local file, you could just import it in the sources where you need it. If it's an external file, one method could be to add the script tag (i.e. append it to <head>) from index.js before you instantiate the app.

Update: You can also copy config/html-template.ejs from your @enact/cli repo to your project and add your scripts to it. Then you need to update your package.json to use the template. For example:

...
  "enact": {
    "theme": "moonstone",
    "template": "html-template.ejs"
  }
...

@JayCanuck
Copy link
Member

Another example can be seen in the Cordova app template where a custom html-template.ejs file is used to include the cordova.js external script.

@lishammel
Copy link

@Sumitha-95 - does this help? Or is your issue still unresolved? thanks.

@Sumitha-95
Copy link
Author

Sumitha-95 commented Apr 11, 2019

I got a workaround.Injected the script manually on app.js.Hence closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants