Sha256: 1d98c5a5d2785d00072ab0442851ff22499675c6c37f29a4d7e8e73668d32d4c

Contents?: true

Size: 959 Bytes

Versions: 2

Compression:

Stored size: 959 Bytes

Contents

# Using external libraries in your Opal app

As described in the getting started docs, opal uses a load path which works
with sprockets to create a set of locations which opal can require files
from. If you want to add a directory to this load path, you can add it to
either the global environment, or a sprockets instance.

### Global Environment

In the `Opal` module, a property `paths` is used to hold the load paths which
`Opal` uses to require files from. You can add a directory to this:

```ruby
Opal.append_path '../my_lib'
```

Now, any ruby files in this directory can be discovered.

### Sprockets instances

`Opal::Environment` is a subclass of the sprockets environment class which
can have instance specific paths added to it. This class will inherit all
global paths, but you can also add your instance paths as:

```ruby
env = Opal::Environment.new
env.append_path '../my_lib'
```

## with Opal::Builder

_WIP_

## With opal-sprockets

_WIP_

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-0.8.1 docs/libraries.md
opal-0.8.1.rc1 docs/libraries.md