https://github.com/mrdziuban/opal-rb-loader
Opal webpack loader
https://github.com/mrdziuban/opal-rb-loader
opal ruby webpack webpack-loader
Last synced: 9 months ago
JSON representation
Opal webpack loader
- Host: GitHub
- URL: https://github.com/mrdziuban/opal-rb-loader
- Owner: mrdziuban
- License: mit
- Created: 2017-02-23T13:12:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-14T16:06:11.000Z (over 9 years ago)
- Last Synced: 2025-09-14T20:24:27.332Z (9 months ago)
- Topics: opal, ruby, webpack, webpack-loader
- Language: JavaScript
- Size: 5.86 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Opal Webpack loader
[](https://www.npmjs.com/package/opal-rb-loader)
### Usage
This is a simple Webpack loader that shells out to [Opal](https://github.com/opal/opal). It was built as an
alternative to [opal-webpack](https://github.com/cj/opal-webpack) because I felt that transpiling files using their
bootstrapped copy of the Opal compiler was too slow.
To use it, first install the package:
```bash
$ npm install --save opal-rb-loader
```
then configure the loader in your Webpack config:
```js
module.exports = {
// ...
module: {
rules: [
{ test: /\.rb$/, loader: 'opal-rb-loader' },
// ...
]
}
}
```
Make sure you have the `opal` binary somewhere in your `PATH`. See below for more details on
[installing Opal](#installing-opal)
### Configuration
The only available option is `includeOpal`, which specifies whether or not the Opal compiler should automatically
include the Opal core libraries when compiling your code. If you set this to false, you should add `require 'opal'`
to the top of your Ruby files. This option defaults to true. To disable including Opal, specify it in the loader
query:
```js
{ test: /\.rb$/, loader: 'opal-rb-loader?includeOpal=false' },
```
### Installing Opal
You can install Opal by running
```bash
$ gem install opal
```
If you'd like to use a bundled version of Opal, setup your Gemfile:
```rb
source 'https://rubygems.org'
gem 'opal'
```
and run `bundle install`. Then when you run `webpack` you can run it with `bundle exec`, and the loader will use the
version of Opal that you installed via bundler.