项目作者: mrdziuban

项目描述 :
Opal webpack loader
高级语言: JavaScript
项目地址: git://github.com/mrdziuban/opal-rb-loader.git
创建时间: 2017-02-23T13:12:39Z
项目社区:https://github.com/mrdziuban/opal-rb-loader

开源协议:MIT License

下载


Opal Webpack loader

npm

Usage

This is a simple Webpack loader that shells out to Opal. It was built as an
alternative to 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:

  1. $ npm install --save opal-rb-loader

then configure the loader in your Webpack config:

  1. module.exports = {
  2. // ...
  3. module: {
  4. rules: [
  5. { test: /\.rb$/, loader: 'opal-rb-loader' },
  6. // ...
  7. ]
  8. }
  9. }

Make sure you have the opal binary somewhere in your PATH. See below for more details on
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:

  1. { test: /\.rb$/, loader: 'opal-rb-loader?includeOpal=false' },

Installing Opal

You can install Opal by running

  1. $ gem install opal

If you’d like to use a bundled version of Opal, setup your Gemfile:

  1. source 'https://rubygems.org'
  2. 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.