How to embed resources in javascript?

In my build I have a text file containing some data that is needed by my program. It’s a multiplatform project and for the JVM and Native targets I simply load the content of the file using FileInputStream and the Unix read/write system calls respectively.

I now want to support Javascript, and I believe the simplest way to handle this is to simply embed the content of this file in the generated Javascript. Ideally I should simply be able to read the content of a string, with everything set up at build time.

Is there a simple way to do this? Perhaps Gradle already has the necessary functionality? If not, is there some way to achieve this?

1 Like