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

[html5 setup doc] new chapter about including js dependencies #17

Merged
merged 3 commits into from
Jan 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions _docs/advanced-setup/html5.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@ To use an external JavaScript library with Lime, you need [Haxe externs](https:/

Members of the Haxe community have already created open source externs for a number of popular JavaScript libraries, so be sure to search [Haxelib](https://lib.haxe.org/search) or [Github](https://github.com/search) to see if JS externs exist for your library before you try to create your own.

### Adding dependencies

The way you add external libraries can vary. Some Haxe externs are configured to use with Lime out of the box (like [haxe-simple-peer](https://github.com/ixiagames/haxe-simple-peer)), so you just use it with `<haxelib name="simple-peer" />`. Other externs may require to include appropriate js dependencies by you. There are three ways for doing so:
T1mL3arn marked this conversation as resolved.
Show resolved Hide resolved

1. Ship the library with your project as a separate file:

```xml
<dependency path="js-libs/someLibrary.js" />
```

`js-libs/someLibrary.js` file will be copied to `lib` directory of the compiled project. You can change the dependency export path with this config:

```xml
<config:html5 dependency-path="newDirName" />
```

2. Embed the library:

```xml
<dependency path="js-libs/someLibrary.js" embed="true"/>
```

The content of `js-libs/someLibrary.js` will be embedded into compiled application's `.js` file.

3. Add remote link to the library:

```xml
<dependency name="https://unpkg.com/[email protected]/simplepeer.min.js" />
```

The resulted `index.html` will have an appropriate `<script>` tag.

## Forums

If you encounter any problems when setting up Lime for HTML5, please visit the [forums](http://community.openfl.org/c/help).